changeset 36153:affa86541a51

Avoid dead code and a memleak.
author reimar
date Tue, 07 May 2013 20:39:18 +0000
parents c3b4a1b48c7d
children 319cbb4d0967
files input/input.c
diffstat 1 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/input/input.c	Tue May 07 20:39:17 2013 +0000
+++ b/input/input.c	Tue May 07 20:39:18 2013 +0000
@@ -1587,6 +1587,7 @@
 
 static int
 mp_input_parse_config(char *file) {
+  int res = 0;
   int fd;
   int eof = 0,comments = 0;
   char *iter,*end;
@@ -1614,16 +1615,15 @@
 	if(errno == EINTR)
 	  continue;
 	mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrReadingInputConfig,file,strerror(errno));
-	close(fd);
-	return 0;
+	break;
       }
       eof = r == 0;
     }
     // Empty buffer : return
     if(!buffer[0]) {
       mp_msg(MSGT_INPUT,MSGL_V,"Input config file %s parsed: %d binds\n",file,n_binds);
-      close(fd);
-      return 1;
+      res = 1;
+      break;
     }
 
     iter = buffer;
@@ -1660,7 +1660,7 @@
       if(!end[0]) { // Key name doesn't fit in the buffer
 	if(buffer == iter) {
 	  mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrBuffer2SmallForKeyName,iter);
-	  return 0;
+	  break;
 	}
 	strmove(buffer,iter);
 	continue;
@@ -1668,8 +1668,7 @@
 	end[0] = 0;
 	if(! mp_input_get_input_from_name(iter,keys)) {
 	  mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrUnknownKey,iter);
-	  close(fd);
-	  return 0;
+	  break;
 	}
       strmove(buffer,end+1);
       continue;
@@ -1691,8 +1690,7 @@
       if(!end[0]) {
 	if(iter == buffer) {
 	  mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrBuffer2SmallForCmd,buffer);
-	  close(fd);
-	  return 0;
+	  break;
 	}
 	strmove(buffer,iter);
 	continue;
@@ -1705,10 +1703,8 @@
       continue;
     }
   }
-  mp_msg(MSGT_INPUT,MSGL_ERR,MSGTR_INPUT_INPUT_ErrWhyHere);
   close(fd);
-  mp_input_set_section(NULL);
-  return 0;
+  return res;
 }
 
 void