From a840cdda6cf7dbfe6858739f718d2ede9e3c375b Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Tue, 19 Jun 2012 15:37:06 +0300 Subject: network: Use av_strerror for getting error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also use ff_neterrno() instead of errno directly (which doesn't work on windows), for getting the error code. Signed-off-by: Martin Storsjö --- libavformat/tcp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libavformat/tcp.c') diff --git a/libavformat/tcp.c b/libavformat/tcp.c index 7e348f7729..e7c6210fc1 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -141,10 +141,12 @@ static int tcp_open(URLContext *h, const char *uri, int flags) optlen = sizeof(ret); getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen); if (ret != 0) { + char errbuf[100]; + ret = AVERROR(ret); + av_strerror(ret, errbuf, sizeof(errbuf)); av_log(h, AV_LOG_ERROR, "TCP connection to %s:%d failed: %s\n", - hostname, port, strerror(ret)); - ret = AVERROR(ret); + hostname, port, errbuf); goto fail; } } -- cgit v1.2.3 From bb6c1abb0e022e1edaa5b3d8bb5abdff4f0c0ff2 Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Tue, 19 Jun 2012 17:50:38 +0300 Subject: tcp: Check the return value from getsockopt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure we actually have an error code in ret, in case getsockopt failed. Signed-off-by: Martin Storsjö --- libavformat/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libavformat/tcp.c') diff --git a/libavformat/tcp.c b/libavformat/tcp.c index e7c6210fc1..f1bad847d0 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -139,7 +139,8 @@ static int tcp_open(URLContext *h, const char *uri, int flags) } /* test error */ optlen = sizeof(ret); - getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen); + if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen)) + ret = AVUNERROR(ff_neterrno()); if (ret != 0) { char errbuf[100]; ret = AVERROR(ret); -- cgit v1.2.3 From 6501dcfb5e3797b66f63de030fabe774b5f4596f Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Tue, 19 Jun 2012 22:08:35 +0100 Subject: Remove unnecessary inclusions of [sys/]time.h Signed-off-by: Mans Rullgard --- avconv.c | 1 - avserver.c | 1 - libavdevice/dv1394.c | 2 -- libavdevice/fbdev.c | 1 - libavdevice/oss_audio.c | 2 -- libavdevice/v4l2.c | 1 - libavformat/rtpproto.c | 1 - libavformat/rtsp.c | 1 - libavformat/rtspenc.c | 1 - libavformat/sapdec.c | 1 - libavformat/sctp.c | 1 - libavformat/tcp.c | 1 - libavformat/udp.c | 1 - libavutil/parseutils.c | 1 - 14 files changed, 16 deletions(-) (limited to 'libavformat/tcp.c') diff --git a/avconv.c b/avconv.c index 9da8d8aeca..7abf10d7b0 100644 --- a/avconv.c +++ b/avconv.c @@ -55,7 +55,6 @@ #if HAVE_SYS_RESOURCE_H #include -#include #include #elif HAVE_GETPROCESSTIMES #include diff --git a/avserver.c b/avserver.c index 5777a08cd3..60509652cd 100644 --- a/avserver.c +++ b/avserver.c @@ -51,7 +51,6 @@ #include #endif #include -#include #include #include #include diff --git a/libavdevice/dv1394.c b/libavdevice/dv1394.c index f48d2b1506..2bb65b6a38 100644 --- a/libavdevice/dv1394.c +++ b/libavdevice/dv1394.c @@ -26,8 +26,6 @@ #include #include #include -#include -#include #include "libavutil/log.h" #include "libavutil/opt.h" diff --git a/libavdevice/fbdev.c b/libavdevice/fbdev.c index f79893a6d4..d789d41afa 100644 --- a/libavdevice/fbdev.c +++ b/libavdevice/fbdev.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/libavdevice/oss_audio.c b/libavdevice/oss_audio.c index e592c32849..60432c5fc5 100644 --- a/libavdevice/oss_audio.c +++ b/libavdevice/oss_audio.c @@ -33,8 +33,6 @@ #include #include #include -#include -#include #include "libavutil/log.h" #include "libavutil/opt.h" diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index b9941d212c..2154b63aa2 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -42,7 +42,6 @@ #else #include #endif -#include #include "libavutil/imgutils.h" #include "libavutil/log.h" #include "libavutil/opt.h" diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 881a188161..e70b89ec9e 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -39,7 +39,6 @@ #if HAVE_POLL_H #include #endif -#include #define RTP_TX_BUF_SIZE (64 * 1024) #define RTP_RX_BUF_SIZE (128 * 1024) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index a70ea04df2..76b5df8400 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -30,7 +30,6 @@ #include "avformat.h" #include "avio_internal.h" -#include #if HAVE_POLL_H #include #endif diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index ad6e485906..c7fb2fa9d9 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -21,7 +21,6 @@ #include "avformat.h" -#include #if HAVE_POLL_H #include #endif diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 46a4b96b93..e377cefda9 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -30,7 +30,6 @@ #if HAVE_POLL_H #include #endif -#include struct SAPState { URLContext *ann_fd; diff --git a/libavformat/sctp.c b/libavformat/sctp.c index 817b0049a9..07de4986d2 100644 --- a/libavformat/sctp.c +++ b/libavformat/sctp.c @@ -39,7 +39,6 @@ #include #include -#include #include #include "config.h" diff --git a/libavformat/tcp.c b/libavformat/tcp.c index f1bad847d0..e77e4c5231 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -28,7 +28,6 @@ #if HAVE_POLL_H #include #endif -#include typedef struct TCPContext { int fd; diff --git a/libavformat/udp.c b/libavformat/udp.c index 0eaed1bfc8..39db263e12 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -35,7 +35,6 @@ #include "network.h" #include "os_support.h" #include "url.h" -#include #ifndef IPV6_ADD_MEMBERSHIP #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index ed147eef3d..34f45eb2d1 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -21,7 +21,6 @@ * misc parsing utilities */ -#include #include #include "avstring.h" -- cgit v1.2.3