? config.cache
? dbus-1.1.1.tar.gz
? test/data/valid-config-files/session.d
? test/name-test/run-with-tmp-session-bus.conf
Index: ChangeLog
===================================================================
RCS file: /cvs/dbus/dbus/ChangeLog,v
retrieving revision 1.1326
diff -u -p -r1.1326 ChangeLog
--- ChangeLog	15 Jun 2007 18:15:41 -0000	1.1326
+++ ChangeLog	15 Jun 2007 19:27:49 -0000
@@ -1,3 +1,17 @@
+2007-06-15  Havoc Pennington  <hp@redhat.com>
+
+	* dbus/dbus-sysdeps.c (_dbus_set_errno_to_zero)
+	(_dbus_get_is_errno_nonzero, _dbus_get_is_errno_eintr)
+	(_dbus_strerror_from_errno): family of functions to abstract
+	errno, though these are somewhat bogus (really we should make our
+	socket wrappers not use errno probably - the issue is that any
+	usage of errno that isn't socket-related probably is not
+	cross-platform, so should either be in a unix-only file that can
+	use errno directly, or is a bug - these general errno wrappers
+	hide issues of this nature in non-socket code, while
+	socket-specific API changes would not since sockets are allowed
+	cross-platform)
+
 2007-06-14  Havoc Pennington  <hp@redhat.com>
 
 	* bus/dispatch.c (check_get_connection_unix_process_id): mop up
Index: bus/activation.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/activation.c,v
retrieving revision 1.50
diff -u -p -r1.50 activation.c
--- bus/activation.c	7 Mar 2007 18:34:01 -0000	1.50
+++ bus/activation.c	15 Jun 2007 19:27:50 -0000
@@ -34,7 +34,9 @@
 #include <dbus/dbus-spawn.h>
 #include <dbus/dbus-timeout.h>
 #include <dbus/dbus-sysdeps.h>
+#ifdef HAVE_ERRNO_H
 #include <errno.h>
+#endif
 
 #define DBUS_SERVICE_SECTION "D-BUS Service"
 #define DBUS_SERVICE_NAME "Name"
Index: bus/config-loader-libxml.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/config-loader-libxml.c,v
retrieving revision 1.8
diff -u -p -r1.8 config-loader-libxml.c
--- bus/config-loader-libxml.c	10 Aug 2004 03:06:59 -0000	1.8
+++ bus/config-loader-libxml.c	15 Jun 2007 19:27:50 -0000
@@ -27,7 +27,9 @@
 #include <libxml/parser.h>
 #include <libxml/globals.h>
 #include <libxml/xmlmemory.h>
+#ifdef HAVE_ERRNO_H
 #include <errno.h>
+#endif
 #include <string.h>
 
 /* About the error handling: 
Index: bus/dir-watch-dnotify.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/dir-watch-dnotify.c,v
retrieving revision 1.3
diff -u -p -r1.3 dir-watch-dnotify.c
--- bus/dir-watch-dnotify.c	19 Oct 2006 19:43:05 -0000	1.3
+++ bus/dir-watch-dnotify.c	15 Jun 2007 19:27:50 -0000
@@ -27,6 +27,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
 
 #include <dbus/dbus-internals.h>
 #include "dir-watch.h"
Index: bus/dir-watch-kqueue.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/dir-watch-kqueue.c,v
retrieving revision 1.2
diff -u -p -r1.2 dir-watch-kqueue.c
--- bus/dir-watch-kqueue.c	19 Oct 2006 19:43:05 -0000	1.2
+++ bus/dir-watch-kqueue.c	15 Jun 2007 19:27:50 -0000
@@ -29,6 +29,10 @@
 #include <signal.h>
 #include <fcntl.h>
 #include <unistd.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
 #include "bus.h"
 #include <dbus/dbus-watch.h>
 
Index: bus/main.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/main.c,v
retrieving revision 1.39
diff -u -p -r1.39 main.c
--- bus/main.c	1 Jun 2007 22:05:42 -0000	1.39
+++ bus/main.c	15 Jun 2007 19:27:51 -0000
@@ -23,15 +23,14 @@
 #include "bus.h"
 #include "driver.h"
 #include <dbus/dbus-internals.h>
-#include <dbus/dbus-watch.h>
-#ifdef DBUS_WIN
-#include <dbus/dbus-sysdeps-win.h>
-#endif
+#include <dbus/dbus-watch.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <signal.h>
+#ifdef HAVE_ERRNO_H
 #include <errno.h>
+#endif
 #include "selinux.h"
 
 static BusContext *context;
Index: bus/selinux.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/selinux.c,v
retrieving revision 1.21
diff -u -p -r1.21 selinux.c
--- bus/selinux.c	13 Jun 2007 20:52:58 -0000	1.21
+++ bus/selinux.c	15 Jun 2007 19:27:51 -0000
@@ -31,7 +31,9 @@
 #ifdef HAVE_SELINUX
 #include <sys/types.h>
 #include <unistd.h>
+#ifdef HAVE_ERRNO_H
 #include <errno.h>
+#endif
 #include <pthread.h>
 #include <syslog.h>
 #include <selinux/selinux.h>
Index: dbus/dbus-server-socket.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-server-socket.c,v
retrieving revision 1.5
diff -u -p -r1.5 dbus-server-socket.c
--- dbus/dbus-server-socket.c	13 Jun 2007 20:52:58 -0000	1.5
+++ dbus/dbus-server-socket.c	15 Jun 2007 19:27:52 -0000
@@ -169,11 +169,11 @@ socket_handle_watch (DBusWatch    *watch
         {
           /* EINTR handled for us */
           
-          if (errno == EAGAIN || errno == EWOULDBLOCK)
+          if (_dbus_get_is_errno_eagain_or_ewouldblock ())
             _dbus_verbose ("No client available to accept after all\n");
           else
             _dbus_verbose ("Failed to accept a client connection: %s\n",
-                           _dbus_strerror (errno));
+                           _dbus_strerror_from_errno ());
 
           SERVER_UNLOCK (server);
         }
Index: dbus/dbus-spawn.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-spawn.c,v
retrieving revision 1.26
diff -u -p -r1.26 dbus-spawn.c
--- dbus/dbus-spawn.c	9 Jun 2007 21:53:18 -0000	1.26
+++ dbus/dbus-spawn.c	15 Jun 2007 19:27:52 -0000
@@ -31,8 +31,10 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <sys/wait.h>
-#include <errno.h>
 #include <stdlib.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
 
 /**
  * @addtogroup DBusInternalsUtils
Index: dbus/dbus-sysdeps-pthread.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-pthread.c,v
retrieving revision 1.6
diff -u -p -r1.6 dbus-sysdeps-pthread.c
--- dbus/dbus-sysdeps-pthread.c	19 Nov 2006 18:23:27 -0000	1.6
+++ dbus/dbus-sysdeps-pthread.c	15 Jun 2007 19:27:52 -0000
@@ -29,6 +29,10 @@
 #include <pthread.h>
 #include <string.h>
 
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
 typedef struct {
   pthread_mutex_t lock; /**< lock protecting count field */
   volatile int count;   /**< count of how many times lock holder has recursively locked */
Index: dbus/dbus-sysdeps-unix.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-unix.c,v
retrieving revision 1.31
diff -u -p -r1.31 dbus-sysdeps-unix.c
--- dbus/dbus-sysdeps-unix.c	14 Jun 2007 21:15:33 -0000	1.31
+++ dbus/dbus-sysdeps-unix.c	15 Jun 2007 19:27:54 -0000
@@ -32,6 +32,7 @@
 #include "dbus-userdb.h"
 #include "dbus-list.h"
 #include "dbus-credentials.h"
+
 #include <sys/types.h>
 #include <stdlib.h>
 #include <string.h>
@@ -2327,7 +2328,8 @@ _dbus_exit (int code)
 
 /**
  * A wrapper around strerror() because some platforms
- * may be lame and not have strerror().
+ * may be lame and not have strerror(). Also, never
+ * returns NULL.
  *
  * @param error_number errno.
  * @returns error description.
@@ -2993,4 +2995,17 @@ _dbus_append_keyring_directory_for_crede
   return FALSE;
 }
 
+
+/**
+ * See if errno is EAGAIN or EWOULDBLOCK (this has to be done differently
+ * for Winsock so is abstracted)
+ *
+ * @returns #TRUE if errno == EAGAIN or errno == EWOULDBLOCK
+ */
+dbus_bool_t
+_dbus_get_is_errno_eagain_or_ewouldblock (void)
+{
+  return errno == EAGAIN || errno == EWOULDBLOCK;
+}
+
 /* tests in dbus-sysdeps-util.c */
Index: dbus/dbus-sysdeps.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.c,v
retrieving revision 1.125
diff -u -p -r1.125 dbus-sysdeps.c
--- dbus/dbus-sysdeps.c	14 Jun 2007 18:34:28 -0000	1.125
+++ dbus/dbus-sysdeps.c	15 Jun 2007 19:27:55 -0000
@@ -967,6 +967,55 @@ _dbus_error_from_errno (int error_number
   return DBUS_ERROR_FAILED;
 }
 
+/**
+ * Assign 0 to the global errno variable
+ */
+void
+_dbus_set_errno_to_zero (void)
+{
+  errno = 0;
+}
+
+/**
+ * See if errno is set
+ * @returns #TRUE if errno is not 0
+ */
+dbus_bool_t
+_dbus_get_is_errno_nonzero (void)
+{
+  return errno != 0;
+}
+
+/**
+ * See if errno is ENOMEM
+ * @returns #TRUE if errno == ENOMEM
+ */
+dbus_bool_t
+_dbus_get_is_errno_enomem (void)
+{
+  return errno == ENOMEM;
+}
+
+/**
+ * See if errno is EINTR
+ * @returns #TRUE if errno == EINTR
+ */
+dbus_bool_t
+_dbus_get_is_errno_eintr (void)
+{
+  return errno == EINTR;
+}
+
+/**
+ * Get error message from errno
+ * @returns _dbus_strerror(errno)
+ */
+const char*
+_dbus_strerror_from_errno (void)
+{
+  return _dbus_strerror (errno);
+}
+
 /** @} end of sysdeps */
 
 /* tests in dbus-sysdeps-util.c */
Index: dbus/dbus-sysdeps.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.h,v
retrieving revision 1.80
diff -u -p -r1.80 dbus-sysdeps.h
--- dbus/dbus-sysdeps.h	14 Jun 2007 21:15:33 -0000	1.80
+++ dbus/dbus-sysdeps.h	15 Jun 2007 19:27:56 -0000
@@ -33,10 +33,6 @@
  * stuff straight out of string.h, so have this here for now.
  */
 #include <string.h>
-
-/* and it would just be annoying to abstract this */
-#include <errno.h>
-
 #include <stdarg.h>
 
 DBUS_BEGIN_DECLS
@@ -315,6 +311,13 @@ dbus_bool_t _dbus_generate_random_ascii 
 
 const char* _dbus_error_from_errno (int error_number);
 
+void        _dbus_set_errno_to_zero                  (void);
+dbus_bool_t _dbus_get_is_errno_nonzero               (void);
+dbus_bool_t _dbus_get_is_errno_eagain_or_ewouldblock (void);
+dbus_bool_t _dbus_get_is_errno_enomem                (void);
+dbus_bool_t _dbus_get_is_errno_eintr                 (void);
+const char* _dbus_strerror_from_errno                (void);
+
 void _dbus_disable_sigpipe (void);
 
 
Index: dbus/dbus-transport-socket.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-transport-socket.c,v
retrieving revision 1.5
diff -u -p -r1.5 dbus-transport-socket.c
--- dbus/dbus-transport-socket.c	9 Jun 2007 21:53:20 -0000	1.5
+++ dbus/dbus-transport-socket.c	15 Jun 2007 19:27:56 -0000
@@ -267,17 +267,16 @@ read_data_into_auth (DBusTransport *tran
     {
       /* EINTR already handled for us */
 
-      if (errno == ENOMEM)
+      if (_dbus_get_is_errno_enomem ())
         {
           *oom = TRUE;
         }
-      else if (errno == EAGAIN ||
-               errno == EWOULDBLOCK)
+      else if (_dbus_get_is_errno_eagain_or_ewouldblock ())
         ; /* do nothing, just return FALSE below */
       else
         {
           _dbus_verbose ("Error reading from remote app: %s\n",
-                         _dbus_strerror (errno));
+                         _dbus_strerror_from_errno ());
           do_io_error (transport);
         }
 
@@ -319,13 +318,12 @@ write_data_from_auth (DBusTransport *tra
     {
       /* EINTR already handled for us */
       
-      if (errno == EAGAIN ||
-          errno == EWOULDBLOCK)
+      if (_dbus_get_is_errno_eagain_or_ewouldblock ())
         ;
       else
         {
           _dbus_verbose ("Error writing to remote app: %s\n",
-                         _dbus_strerror (errno));
+                         _dbus_strerror_from_errno ());
           do_io_error (transport);
         }
     }
@@ -613,13 +611,12 @@ do_writing (DBusTransport *transport)
         {
           /* EINTR already handled for us */
           
-          if (errno == EAGAIN ||
-              errno == EWOULDBLOCK)
+          if (_dbus_get_is_errno_eagain_or_ewouldblock ())
             goto out;
           else
             {
               _dbus_verbose ("Error writing to remote app: %s\n",
-                             _dbus_strerror (errno));
+                             _dbus_strerror_from_errno ());
               do_io_error (transport);
               goto out;
             }
@@ -749,19 +746,18 @@ do_reading (DBusTransport *transport)
     {
       /* EINTR already handled for us */
 
-      if (errno == ENOMEM)
+      if (_dbus_get_is_errno_enomem ())
         {
           _dbus_verbose ("Out of memory in read()/do_reading()\n");
           oom = TRUE;
           goto out;
         }
-      else if (errno == EAGAIN ||
-               errno == EWOULDBLOCK)
+      else if (_dbus_get_is_errno_eagain_or_ewouldblock ())
         goto out;
       else
         {
           _dbus_verbose ("Error reading from remote app: %s\n",
-                         _dbus_strerror (errno));
+                         _dbus_strerror_from_errno ());
           do_io_error (transport);
           goto out;
         }
@@ -1038,7 +1034,7 @@ socket_do_iteration (DBusTransport *tran
     again:
       poll_res = _dbus_poll (&poll_fd, 1, poll_timeout);
 
-      if (poll_res < 0 && errno == EINTR)
+      if (poll_res < 0 && _dbus_get_is_errno_eintr ())
 	goto again;
 
       if (flags & DBUS_ITERATION_BLOCK)
@@ -1081,7 +1077,7 @@ socket_do_iteration (DBusTransport *tran
       else
         {
           _dbus_verbose ("Error from _dbus_poll(): %s\n",
-                         _dbus_strerror (errno));
+                         _dbus_strerror_from_errno ());
         }
     }
 
