[FFmpeg-devel] [PATCH]: remove useless fd_max definition in libavformat/tcp.c

avcoder ffmpeg
Fri Jan 8 09:38:15 CET 2010


Dear:

part1_remove_useless_fd_max.diff remove useless fd_max defintion

Index: libavformat/tcp.c
===================================================================
--- libavformat/tcp.c (revision 21080)
+++ libavformat/tcp.c (working copy)
@@ -38,7 +38,7 @@
     int port, fd = -1;
     TCPContext *s = NULL;
     fd_set wfds;
-    int fd_max, ret;
+    int ret;
     struct timeval tv;
     socklen_t optlen;
     char hostname[1024],proto[1024],path[1024];
@@ -77,12 +77,11 @@
                 ret = AVERROR(EINTR);
                 goto fail1;
             }
-            fd_max = fd;
             FD_ZERO(&wfds);
             FD_SET(fd, &wfds);
             tv.tv_sec = 0;
             tv.tv_usec = 100 * 1000;
-            ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
+            ret = select(fd + 1, NULL, &wfds, NULL, &tv);
             if (ret > 0 && FD_ISSET(fd, &wfds))
                 break;
         }
@@ -112,19 +111,18 @@
 static int tcp_read(URLContext *h, uint8_t *buf, int size)
 {
     TCPContext *s = h->priv_data;
-    int len, fd_max, ret;
+    int len, ret;
     fd_set rfds;
     struct timeval tv;

     for (;;) {
         if (url_interrupt_cb())
             return AVERROR(EINTR);
-        fd_max = s->fd;
         FD_ZERO(&rfds);
         FD_SET(s->fd, &rfds);
         tv.tv_sec = 0;
         tv.tv_usec = 100 * 1000;
-        ret = select(fd_max + 1, &rfds, NULL, NULL, &tv);
+        ret = select(s->fd + 1, &rfds, NULL, NULL, &tv);
         if (ret > 0 && FD_ISSET(s->fd, &rfds)) {
             len = recv(s->fd, buf, size, 0);
             if (len < 0) {
@@ -141,7 +139,7 @@
 static int tcp_write(URLContext *h, uint8_t *buf, int size)
 {
     TCPContext *s = h->priv_data;
-    int ret, size1, fd_max, len;
+    int ret, size1, len;
     fd_set wfds;
     struct timeval tv;

@@ -149,12 +147,11 @@
     while (size > 0) {
         if (url_interrupt_cb())
             return AVERROR(EINTR);
-        fd_max = s->fd;
         FD_ZERO(&wfds);
         FD_SET(s->fd, &wfds);
         tv.tv_sec = 0;
         tv.tv_usec = 100 * 1000;
-        ret = select(fd_max + 1, NULL, &wfds, NULL, &tv);
+        ret = select(s->fd + 1, NULL, &wfds, NULL, &tv);
         if (ret > 0 && FD_ISSET(s->fd, &wfds)) {
             len = send(s->fd, buf, size, 0);
             if (len < 0) {


------------------------------------
part2_cosmetics_merge_declaration.diff : cosmetics: merge two "int"
decalaration

Index: libavformat/tcp.c
===================================================================
--- libavformat/tcp.c (revision 251)
+++ libavformat/tcp.c (working copy)
@@ -35,10 +35,9 @@
 static int tcp_open(URLContext *h, const char *uri, int flags)
 {
     struct sockaddr_in dest_addr;
-    int port, fd = -1;
+    int port, ret, fd = -1;
     TCPContext *s = NULL;
     fd_set wfds;
-    int ret;
     struct timeval tv;
     socklen_t optlen;
     char hostname[1024],proto[1024],path[1024];

-- 
-----------------------------------------------------------------------------------------
My key fingerprint: d1:03:f5:32:26:ff:d7:3c:e4:42:e3:51:ec:92:78:b2
Inspired by http://www.nextplayer.net. Your potential. Our passion.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: part1_remove_useless_fd_max.diff
Type: application/octet-stream
Size: 2242 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100108/7f7f2541/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: part2_cosmetics_merge_declaration.diff
Type: application/octet-stream
Size: 500 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100108/7f7f2541/attachment-0001.obj>



More information about the ffmpeg-devel mailing list