Hi

I see compilation warnings when building vim-7.4.1493 with:

$ ./configure --with-features=normal --enable-gui=none --enable-channel=no
$ make
...
$ gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -Wall -Wextra
-Wmissing-prototypes -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DU_DEBUG
-DEXITFREE    -o objects/os_unix.o os_unix.c
os_unix.c: In function ‘mch_start_job’:
os_unix.c:5040:50: warning: unused parameter ‘options’ [-Wunused-parameter]
 mch_start_job(char **argv, job_T *job, jobopt_T *options)
                                                  ^
os_unix.c:5136:5: warning: ‘fd_out[1]’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
     close(fd_out[1]);
     ^
os_unix.c:5140:2: warning: ‘fd_err[1]’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
  close(fd_err[1]);
  ^

Closing uninitialized file descriptor is a bug.

fd_out, fd_in and fd_err are only really used when FEAT_CHANNEL
is defined, so attached patch fixes it by putting them inside
#ifdef FEAT_CHANNEL.

Regards
Dominique

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/os_unix.c b/src/os_unix.c
index bcfffb4..ed2b129 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -5037,16 +5037,15 @@ error:
 
 #if defined(FEAT_JOB) || defined(PROTO)
     void
-mch_start_job(char **argv, job_T *job, jobopt_T *options)
+mch_start_job(char **argv, job_T *job, jobopt_T *options UNUSED)
 {
     pid_t	pid;
+# ifdef FEAT_CHANNEL
     int		fd_in[2];	/* for stdin */
     int		fd_out[2];	/* for stdout */
     int		fd_err[2];	/* for stderr */
-# ifdef FEAT_CHANNEL
     channel_T	*channel = NULL;
     int		use_out_for_err = options->jo_io[PART_ERR] == JIO_OUT;
-#endif
 
     /* default is to fail */
     job->jv_status = JOB_FAILED;
@@ -5055,7 +5054,6 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options)
     fd_err[0] = -1;
 
     /* TODO: without the channel feature connect the child to /dev/null? */
-# ifdef FEAT_CHANNEL
     /* Open pipes for stdin, stdout, stderr. */
     if (pipe(fd_in) < 0 || pipe(fd_out) < 0
 				    || (!use_out_for_err && pipe(fd_err) < 0))
@@ -5114,7 +5112,6 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options)
 	close(1);
 	ignored = dup(fd_out[1]);
 	close(fd_out[1]);
-
 # endif
 
 	/* See above for type of argv. */
@@ -5131,14 +5128,12 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options)
     job->jv_channel = channel;
 # endif
 
+# ifdef FEAT_CHANNEL
     /* child stdin, stdout and stderr */
     close(fd_in[0]);
     close(fd_out[1]);
-# ifdef FEAT_CHANNEL
     if (!use_out_for_err)
-# endif
 	close(fd_err[1]);
-# ifdef FEAT_CHANNEL
     channel_set_pipes(channel, fd_in[1], fd_out[0],
 				    use_out_for_err ? INVALID_FD : fd_err[0]);
     channel_set_job(channel, job, options);
@@ -5149,11 +5144,10 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options)
 
     return;
 
-failed:
+failed: ;
 # ifdef FEAT_CHANNEL
     if (channel != NULL)
 	channel_free(channel);
-# endif
     if (fd_in[0] >= 0)
     {
 	close(fd_in[0]);
@@ -5169,6 +5163,7 @@ failed:
 	close(fd_err[0]);
 	close(fd_err[1]);
     }
+# endif
 }
 
     char *

Raspunde prin e-mail lui