From 8fa36ae09dddb1b639b4df5d505c0dbcf4e916e4 Mon Sep 17 00:00:00 2001 From: François Revol Date: Tue, 13 Feb 2007 18:26:14 +0000 Subject: This fixes error handling for BeOS, removing the need for some ifdefs. AVERROR_ defines are moved to avcodec.h as they are needed in there as well. Feel free to move that to avutil/common.h. Bumped up avcodec/format version numbers as though it's binary compatible we will want to rebuild apps as error values changed. Please from now on use return AVERROR(EFOO) instead of the ugly return -EFOO in your code. This also removes the need for berrno.h. Originally committed as revision 7965 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/tcp.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'libavformat/tcp.c') diff --git a/libavformat/tcp.c b/libavformat/tcp.c index be8a4bb0bb..fa9e13587f 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -62,7 +62,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) s = av_malloc(sizeof(TCPContext)); if (!s) - return -ENOMEM; + return AVERROR(ENOMEM); h->priv_data = s; if (port <= 0 || port >= 65536) @@ -90,7 +90,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags) /* wait until we are connected or until abort */ for(;;) { if (url_interrupt_cb()) { - ret = -EINTR; + ret = AVERROR(EINTR); goto fail1; } fd_max = fd; @@ -130,7 +130,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size) for (;;) { if (url_interrupt_cb()) - return -EINTR; + return AVERROR(EINTR); fd_max = s->fd; FD_ZERO(&rfds); FD_SET(s->fd, &rfds); @@ -141,11 +141,7 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size) len = recv(s->fd, buf, size, 0); if (len < 0) { if (errno != EINTR && errno != EAGAIN) -#ifdef __BEOS__ - return errno; -#else - return -errno; -#endif + return AVERROR(errno); } else return len; } else if (ret < 0) { return -1; @@ -163,7 +159,7 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size) size1 = size; while (size > 0) { if (url_interrupt_cb()) - return -EINTR; + return AVERROR(EINTR); fd_max = s->fd; FD_ZERO(&wfds); FD_SET(s->fd, &wfds); @@ -173,13 +169,8 @@ static int tcp_write(URLContext *h, uint8_t *buf, int size) if (ret > 0 && FD_ISSET(s->fd, &wfds)) { len = send(s->fd, buf, size, 0); if (len < 0) { - if (errno != EINTR && errno != EAGAIN) { -#ifdef __BEOS__ - return errno; -#else - return -errno; -#endif - } + if (errno != EINTR && errno != EAGAIN) + return AVERROR(errno); continue; } size -= len; -- cgit v1.2.3