[MPlayer-dev-eng] [PATCHv2 4/8] stream ftp: Revise file descriptor usage

Alexander Strasser eclipse7 at gmx.net
Sat Nov 17 01:02:10 CET 2012


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

Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 stream/stream_ftp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/stream/stream_ftp.c b/stream/stream_ftp.c
index 3f666a0..3aa3b09 100644
--- a/stream/stream_ftp.c
+++ b/stream/stream_ftp.c
@@ -60,7 +60,7 @@ static struct stream_priv_s {
   NULL,
   NULL,
 
-  0,
+  -1,
   0,0,
   NULL
 };
@@ -361,7 +361,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
 
@@ -397,14 +397,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);
-- 
1.7.10.2.552.gaa3bb87


More information about the MPlayer-dev-eng mailing list