dbus/dbus dbus-server-unix.c, 1.29, 1.30 dbus-spawn.c, 1.21, 1.22 dbus-sysdeps.c, 1.110, 1.111

John Palmieri johnp at kemper.freedesktop.org
Thu Sep 7 11:24:13 PDT 2006


Update of /cvs/dbus/dbus/dbus
In directory kemper:/tmp/cvs-serv26323/dbus

Modified Files:
	dbus-server-unix.c dbus-spawn.c dbus-sysdeps.c 
Log Message:
* Clean up close calls to use _dbus_close (Patch from 
  Kimmo Hämäläinen <kimmo dot hamalainen at nokia dot com>)


Index: dbus-server-unix.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-server-unix.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- dbus-server-unix.c	25 Oct 2005 15:57:13 -0000	1.29
+++ dbus-server-unix.c	7 Sep 2006 18:24:11 -0000	1.30
@@ -102,7 +102,7 @@
   transport = _dbus_transport_new_for_fd (client_fd, &server->guid_hex, NULL);
   if (transport == NULL)
     {
-      close (client_fd);
+      _dbus_close (client_fd, NULL);
       SERVER_UNLOCK (server);
       return FALSE;
     }
@@ -219,7 +219,7 @@
       unix_server->watch = NULL;
     }
   
-  close (unix_server->fd);
+  _dbus_close (unix_server->fd, NULL);
   unix_server->fd = -1;
 
   if (unix_server->socket_name != NULL)
@@ -436,7 +436,7 @@
   if (server == NULL)
     {
       dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
-      close (listen_fd);
+      _dbus_close (listen_fd, NULL);
       _dbus_string_free (&address);
       return NULL;
     }

Index: dbus-spawn.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-spawn.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- dbus-spawn.c	28 Jun 2005 15:14:21 -0000	1.21
+++ dbus-spawn.c	7 Sep 2006 18:24:11 -0000	1.22
@@ -276,13 +276,13 @@
            * a hangup and then the babysitter will
            * quit itself.
            */
-          close (sitter->socket_to_babysitter);
+          _dbus_close (sitter->socket_to_babysitter, NULL);
           sitter->socket_to_babysitter = -1;
         }
 
       if (sitter->error_pipe_from_child >= 0)
         {
-          close (sitter->error_pipe_from_child);
+          _dbus_close (sitter->error_pipe_from_child, NULL);
           sitter->error_pipe_from_child = -1;
         }
 
@@ -470,7 +470,7 @@
 close_socket_to_babysitter (DBusBabysitter *sitter)
 {
   _dbus_verbose ("Closing babysitter\n");
-  close (sitter->socket_to_babysitter);
+  _dbus_close (sitter->socket_to_babysitter, NULL);
   sitter->socket_to_babysitter = -1;
 }
 
@@ -478,7 +478,7 @@
 close_error_pipe_from_child (DBusBabysitter *sitter)
 {
   _dbus_verbose ("Closing child error\n");
-  close (sitter->error_pipe_from_child);
+  _dbus_close (sitter->error_pipe_from_child, NULL);
   sitter->error_pipe_from_child = -1;
 }
 
@@ -753,7 +753,7 @@
     return -1;
   else
     {
-      ret = close (*fd);
+      ret = _dbus_close (*fd, NULL);
       *fd = -1;
     }
 

Index: dbus-sysdeps.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- dbus-sysdeps.c	6 Sep 2006 00:14:06 -0000	1.110
+++ dbus-sysdeps.c	7 Sep 2006 18:24:11 -0000	1.111
@@ -435,7 +435,7 @@
         {
           dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
                       "Abstract socket name too long\n");
-          close (fd);
+          _dbus_close (fd, NULL);
           return -1;
 	}
 	
@@ -444,7 +444,7 @@
 #else /* HAVE_ABSTRACT_SOCKETS */
       dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
                       "Operating system does not support abstract socket namespace\n");
-      close (fd);
+      _dbus_close (fd, NULL);
       return -1;
 #endif /* ! HAVE_ABSTRACT_SOCKETS */
     }
@@ -454,7 +454,7 @@
         {
           dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
                       "Socket name too long\n");
-          close (fd);
+          _dbus_close (fd, NULL);
           return -1;
 	}
 
@@ -468,7 +468,7 @@
                       "Failed to connect to socket %s: %s",
                       path, _dbus_strerror (errno));
 
-      close (fd);
+      _dbus_close (fd, NULL);
       fd = -1;
       
       return -1;
@@ -478,7 +478,7 @@
     {
       _DBUS_ASSERT_ERROR_IS_SET (error);
       
-      close (fd);
+      _dbus_close (fd, NULL);
       fd = -1;
 
       return -1;
@@ -543,7 +543,7 @@
         {
           dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
                       "Abstract socket name too long\n");
-          close (listen_fd);
+          _dbus_close (listen_fd, NULL);
           return -1;
 	}
       
@@ -552,7 +552,7 @@
 #else /* HAVE_ABSTRACT_SOCKETS */
       dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED,
                       "Operating system does not support abstract socket namespace\n");
-      close (listen_fd);
+      _dbus_close (listen_fd, NULL);
       return -1;
 #endif /* ! HAVE_ABSTRACT_SOCKETS */
     }
@@ -580,7 +580,7 @@
         {
           dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
                       "Abstract socket name too long\n");
-          close (listen_fd);
+          _dbus_close (listen_fd, NULL);
           return -1;
 	}
 	
@@ -592,7 +592,7 @@
       dbus_set_error (error, _dbus_error_from_errno (errno),
                       "Failed to bind socket \"%s\": %s",
                       path, _dbus_strerror (errno));
-      close (listen_fd);
+      _dbus_close (listen_fd, NULL);
       return -1;
     }
 
@@ -601,14 +601,14 @@
       dbus_set_error (error, _dbus_error_from_errno (errno),
                       "Failed to listen on socket \"%s\": %s",
                       path, _dbus_strerror (errno));
-      close (listen_fd);
+      _dbus_close (listen_fd, NULL);
       return -1;
     }
 
   if (!_dbus_set_fd_nonblocking (listen_fd, error))
     {
       _DBUS_ASSERT_ERROR_IS_SET (error);
-      close (listen_fd);
+      _dbus_close (listen_fd, NULL);
       return -1;
     }
   
@@ -666,7 +666,7 @@
                       _dbus_error_from_errno (errno),
                       "Failed to lookup hostname: %s",
                       host);
-      close (fd);
+      _dbus_close (fd, NULL);
       return -1;
     }
   
@@ -684,7 +684,7 @@
                       "Failed to connect to socket %s:%d %s",
                       host, port, _dbus_strerror (errno));
 
-      close (fd);
+      _dbus_close (fd, NULL);
       fd = -1;
       
       return -1;
@@ -692,7 +692,7 @@
 
   if (!_dbus_set_fd_nonblocking (fd, error))
     {
-      close (fd);
+      _dbus_close (fd, NULL);
       fd = -1;
 
       return -1;
@@ -740,7 +740,7 @@
                       _dbus_error_from_errno (errno),
                       "Failed to lookup hostname: %s",
                       host);
-      close (listen_fd);
+      _dbus_close (listen_fd, NULL);
       return -1;
     }
   
@@ -756,7 +756,7 @@
       dbus_set_error (error, _dbus_error_from_errno (errno),
                       "Failed to bind socket \"%s:%d\": %s",
                       host, port, _dbus_strerror (errno));
-      close (listen_fd);
+      _dbus_close (listen_fd, NULL);
       return -1;
     }
 
@@ -765,13 +765,13 @@
       dbus_set_error (error, _dbus_error_from_errno (errno),  
                       "Failed to listen on socket \"%s:%d\": %s",
                       host, port, _dbus_strerror (errno));
-      close (listen_fd);
+      _dbus_close (listen_fd, NULL);
       return -1;
     }
 
   if (!_dbus_set_fd_nonblocking (listen_fd, error))
     {
-      close (listen_fd);
+      _dbus_close (listen_fd, NULL);
       return -1;
     }
   
@@ -2123,7 +2123,7 @@
       _dbus_verbose ("fstat() failed: %s",
                      _dbus_strerror (errno));
       
-      close (fd);
+      _dbus_close (fd, NULL);
       
       return FALSE;
     }
@@ -2133,7 +2133,7 @@
       dbus_set_error (error, DBUS_ERROR_FAILED,
                       "File size %lu of \"%s\" is too large.",
                       (unsigned long) sb.st_size, filename_c);
-      close (fd);
+      _dbus_close (fd, NULL);
       return FALSE;
     }
   
@@ -2157,7 +2157,7 @@
               _dbus_verbose ("read() failed: %s",
                              _dbus_strerror (errno));
               
-              close (fd);
+              _dbus_close (fd, NULL);
               _dbus_string_set_length (str, orig_len);
               return FALSE;
             }
@@ -2165,7 +2165,7 @@
             total += bytes_read;
         }
 
-      close (fd);
+      _dbus_close (fd, NULL);
       return TRUE;
     }
   else if (sb.st_size != 0)
@@ -2174,12 +2174,12 @@
       dbus_set_error (error, DBUS_ERROR_FAILED,
                       "\"%s\" is not a regular file",
                       filename_c);
-      close (fd);
+      _dbus_close (fd, NULL);
       return FALSE;
     }
   else
     {
-      close (fd);
+      _dbus_close (fd, NULL);
       return TRUE;
     }
 }
@@ -2278,7 +2278,7 @@
       total += bytes_written;
     }
 
-  if (close (fd) < 0)
+  if (!_dbus_close (fd, NULL))
     {
       dbus_set_error (error, _dbus_error_from_errno (errno),
                       "Could not close file %s: %s",
@@ -2309,7 +2309,7 @@
    */
 
   if (fd >= 0)
-    close (fd);
+    _dbus_close (fd, NULL);
         
   if (need_unlink && unlink (tmp_filename_c) < 0)
     _dbus_verbose ("Failed to unlink temp file %s: %s\n",
@@ -2352,7 +2352,7 @@
       return FALSE;
     }
 
-  if (close (fd) < 0)
+  if (!_dbus_close (fd, NULL))
     {
       dbus_set_error (error,
                       DBUS_ERROR_FAILED,
@@ -2575,7 +2575,7 @@
 
   if (_dbus_read (fd, str, n_bytes) != n_bytes)
     {
-      close (fd);
+      _dbus_close (fd, NULL);
       _dbus_string_set_length (str, old_len);
       return pseudorandom_generate_random_bytes (str, n_bytes);
     }
@@ -2583,7 +2583,7 @@
   _dbus_verbose ("Read %d bytes from /dev/urandom\n",
                  n_bytes);
   
-  close (fd);
+  _dbus_close (fd, NULL);
   
   return TRUE;
 }
@@ -2965,8 +2965,8 @@
       dbus_set_error (error, _dbus_error_from_errno (errno),
                       "Could not set full-duplex pipe nonblocking");
       
-      close (fds[0]);
-      close (fds[1]);
+      _dbus_close (fds[0], NULL);
+      _dbus_close (fds[1], NULL);
       
       return FALSE;
     }



More information about the dbus-commit mailing list