[MPlayer-cvslog] r35430 - trunk/stream/stream_ftp.c

al subversion at mplayerhq.hu
Tue Nov 20 23:19:45 CET 2012


Author: al
Date: Tue Nov 20 23:19:45 2012
New Revision: 35430

Log:
stream ftp: Revise file descriptor usage

* Set unbound descriptor variables to -1
* Always test >= 0 to see if a variable refers to a valid descriptor

Modified:
   trunk/stream/stream_ftp.c

Modified: trunk/stream/stream_ftp.c
==============================================================================
--- trunk/stream/stream_ftp.c	Tue Nov 20 23:18:25 2012	(r35429)
+++ trunk/stream/stream_ftp.c	Tue Nov 20 23:19:45 2012	(r35430)
@@ -60,7 +60,7 @@ static struct stream_priv_s {
   NULL,
   NULL,
 
-  0,
+  -1,
   0,0,
   NULL
 };
@@ -359,7 +359,7 @@ static int seek(stream_t *s,off_t newpos
 
     // First close the fd
     closesocket(s->fd);
-    s->fd = 0;
+    s->fd = -1;
 
     // Send send the telnet sequence needed to make the server react
 
@@ -395,14 +395,14 @@ static void close_f(stream_t *s) {
 
   if(!p) return;
 
-  if(s->fd > 0) {
+  if(s->fd >= 0) {
     closesocket(s->fd);
-    s->fd = 0;
+    s->fd = -1;
   }
 
   FtpSendCmd("QUIT",p,NULL);
 
-  if(p->handle) closesocket(p->handle);
+  if(p->handle >= 0) closesocket(p->handle);
   free(p->buf);
 
   m_struct_free(&stream_opts,p);


More information about the MPlayer-cvslog mailing list