Warning fixes -- dbusbind.
authorSteve Youngs <steve@sxemacs.org>
Sun, 29 Jan 2012 07:53:00 +0000 (17:53 +1000)
committerSteve Youngs <steve@sxemacs.org>
Sun, 29 Jan 2012 07:53:00 +0000 (17:53 +1000)
This changeset fixes all but 4 or 5 compiler warnings in dbusbind.  The
warnings that are left are some "implicit declaration of function 'foo'"
for some GNU/Emacs functions that I don't yet know what to do with.

* modules/dbus/dbusbind.c (xd_find_watch_fd): Don't use
`dbus_watch_get_fd()', it's deprecated.

* modules/dbus/dbusbind.c (Fdbus_init_bus): Initialise busp to
NULL.

* modules/dbus/dbusbind.c (Fdbus_method_return_internal):
Initialise serial to 0.

* modules/dbus/dbusbind.c (Fdbus_method_error_internal): Ditto.

* modules/dbus/dbusbind.c (Fdbus_register_service): If all else
fails, return Qnil.

* modules/dbus/dbusbind.h (SBYTES): No need to call XSTRING as
XSTRING_LENGTH does that for us.

* modules/dbus/dbusbind.h (XD_ERROR): Correctly cast mess to work
right for our make_string().

* modules/dbus/dbusbind.h (syms_of_dbusbind): Add.

Signed-off-by: Steve Youngs <steve@sxemacs.org>
modules/dbus/dbusbind.c
modules/dbus/dbusbind.h

index ce23c4d..8c57740 100644 (file)
@@ -1,7 +1,7 @@
 /* dbusbind.c -- Elisp bindings for D-Bus. */
 
 /*
- * Time-stamp: <Sunday Jan 29, 2012 00:09:35 steve>
+ * Time-stamp: <Sunday Jan 29, 2012 17:41:26 steve>
  * Created:    <2012-01-03>
  * Maintainer: Steve Youngs <steve@sxemacs.org>
  * Homepage:   http://www.sxemacs.org/
@@ -752,14 +752,10 @@ xd_initialize (Lisp_Object bus, int raise_error)
 static int
 xd_find_watch_fd (DBusWatch *watch)
 {
-#if HAVE_DBUS_WATCH_GET_UNIX_FD
-       /* TODO: Reverse these on Win32, which prefers the opposite.  */
        int fd = dbus_watch_get_unix_fd (watch);
-       if (fd == -1)
+       if (fd == -1) {
                fd = dbus_watch_get_socket (watch);
-#else
-       int fd = dbus_watch_get_fd (watch);
-#endif
+       }
        return fd;
 }
 
@@ -834,7 +830,7 @@ Initialize connection to D-Bus BUS.
       (bus))
 {
        DBusConnection *connection;
-       void *busp;
+       void *busp = NULL;
 
        /* Check parameter.  */
        if (SYMBOLP (bus))
@@ -1282,12 +1278,11 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE
        RETURN_UNGCPRO (result);
 }
 
-DEFUN("dbus-method-return-internal", Fdbus_method_return_internal,
-      3, MANY, 0, /*
+DEFUN("dbus-method-return-internal", Fdbus_method_return_internal, 3, MANY, 0, /*
 Return for message SERIAL on the D-Bus BUS.
 This is an internal function, it shall not be used outside dbus.el.
 
-usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS)
+usage: \(dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS\)
 */
       (int nargs, Lisp_Object *args))
 {
@@ -1296,7 +1291,7 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS)
        DBusConnection *connection;
        DBusMessage *dmessage;
        DBusMessageIter iter;
-       dbus_uint32_t serial;
+       dbus_uint32_t serial = 0;
        unsigned int ui_serial, dtype;
        int i;
        char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
@@ -1371,8 +1366,7 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS)
        return Qt;
 }
 
-DEFUN("dbus-method-error-internal", Fdbus_method_error_internal,
-       3, MANY, 0, /*
+DEFUN("dbus-method-error-internal", Fdbus_method_error_internal, 3, MANY, 0, /*
 Return error message for message SERIAL on the D-Bus BUS.
 This is an internal function, it shall not be used outside dbus.el.
 
@@ -1385,7 +1379,7 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS)
        DBusConnection *connection;
        DBusMessage *dmessage;
        DBusMessageIter iter;
-       dbus_uint32_t serial;
+       dbus_uint32_t serial = 0;
        unsigned int ui_serial, dtype;
        int i;
        char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
@@ -1887,6 +1881,7 @@ usage: (dbus-register-service BUS SERVICE &rest FLAGS)
        default:
                /* This should not happen.  */
                XD_SIGNAL2 (build_string ("Could not register service"), service);
+               return Qnil;
        }
 }
 
index 0daf493..505af77 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 /*
- * Time-stamp: <Sunday Jan 29, 2012 00:09:59 steve>
+ * Time-stamp: <Sunday Jan 29, 2012 17:45:16 steve>
  * Created:    <2012-01-22>
  * Author:     Steve Youngs <steve@sxemacs.org>
  * Maintainer: Steve Youngs <steve@sxemacs.org>
@@ -73,7 +73,7 @@
 #define SREF(string, index)    (SDATA (string)[index] + 0)
 #define SSET(string, index, new) (SDATA (string)[index] = (new))
 #define SCHARS(string)         (XSTRING (string)->size + 0)
-#define SBYTES(string)         (XSTRING_LENGTH (XSTRING (string)) + 0)
+#define SBYTES(string)         (XSTRING_LENGTH (string + 0))
 
 /* Avoid "differ in sign" warnings.  */
 #define SSDATA(x)  ((char *) SDATA (x))
@@ -200,9 +200,11 @@ Lisp_Object Q_test;
 #define XD_ERROR(error)                                                        \
        do {                                                            \
                /* Remove the trailing newline.  */                     \
-               char const *mess = error.message;                       \
-               char const *nl = strchr (mess, '\n');                   \
-               Lisp_Object err = make_string (mess, nl ? nl - mess : strlen (mess)); \
+               const char *mess = error.message;                       \
+               const char *nl = strchr (mess, '\n');                   \
+               Lisp_Object err = make_string                           \
+                       ((const Bufbyte *)mess,                         \
+                        nl ? nl - mess : strlen (mess));               \
                dbus_error_free (&error);                               \
                XD_SIGNAL1 (err);                                       \
        } while (0)
@@ -317,8 +319,9 @@ Lisp_Object Q_test;
        while (0)
 
 
+void syms_of_dbusbind(void);
 
-#endif
+#endif /* _DBUSBIND_H */