Remove redundant close() calls
authorMichel HERMIER <hermier@frugalware.org>
Fri, 9 Nov 2012 15:53:46 +0000 (15:53 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 9 Nov 2012 16:07:53 +0000 (16:07 +0000)
The dup2() calls immediately afterwards will close the "destination" fd
if necessary.

[commit message added -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
dbus/dbus-sysdeps-unix.c

index 55743b193552f6701d74f660660a383aa795c7f9..a03105926ba8669cac45ab5e6a368df42a54c9f3 100644 (file)
@@ -3300,15 +3300,12 @@ _read_subprocess_line_argv (const char *progpath,
       /* set-up stdXXX */
       close (result_pipe[READ_END]);
       close (errors_pipe[READ_END]);
-      close (0);                /* close stdin */
-      close (1);                /* close stdout */
-      close (2);                /* close stderr */
 
-      if (dup2 (fd, 0) == -1)
+      if (dup2 (fd, 0) == -1) /* setup stdin */
         _exit (1);
-      if (dup2 (result_pipe[WRITE_END], 1) == -1)
+      if (dup2 (result_pipe[WRITE_END], 1) == -1) /* setup stdout */
         _exit (1);
-      if (dup2 (errors_pipe[WRITE_END], 2) == -1)
+      if (dup2 (errors_pipe[WRITE_END], 2) == -1) /* setup stderr */
         _exit (1);
 
       _dbus_close_all ();