From 59d6fe8344313c6e31a06b7ebd666e9f7be27ff2 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 13 Mar 2011 20:21:32 -0700 Subject: [PATCH] * dbusbind.c: Pointer signedness fixes. (xd_signature, xd_append_arg, xd_initialize): (Fdbus_call_method, Fdbus_call_method_asynchronously): (Fdbus_method_return_internal, Fdbus_method_error_internal): (Fdbus_send_signal, xd_read_message_1, Fdbus_register_service): (Fdbus_register_signal): Use SSDATA when the context wants char *. --- src/ChangeLog | 9 +++++++++ src/dbusbind.c | 45 ++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bad9b8dd4b..b062bfdf06 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2011-03-14 Paul Eggert + + * dbusbind.c: Pointer signedness fixes. + (xd_signature, xd_append_arg, xd_initialize): + (Fdbus_call_method, Fdbus_call_method_asynchronously): + (Fdbus_method_return_internal, Fdbus_method_error_internal): + (Fdbus_send_signal, xd_read_message_1, Fdbus_register_service): + (Fdbus_register_signal): Use SSDATA when the context wants char *. + 2011-03-13 Chong Yidong * buffer.h (BUF_BEGV, BUF_BEGV_BYTE, BUF_ZV, BUF_ZV_BYTE, BUF_PT) diff --git a/src/dbusbind.c b/src/dbusbind.c index 7e5104026c..bf19605a34 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -325,7 +325,7 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis if ((subtype == DBUS_TYPE_SIGNATURE) && STRINGP (CAR_SAFE (XD_NEXT_VALUE (elt))) && NILP (CDR_SAFE (XD_NEXT_VALUE (elt)))) - strcpy (x, SDATA (CAR_SAFE (XD_NEXT_VALUE (elt)))); + strcpy (x, SSDATA (CAR_SAFE (XD_NEXT_VALUE (elt)))); while (!NILP (elt)) { @@ -531,7 +531,7 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) but by not encoding it, we guarantee it's valid utf-8, even if it contains eight-bit-bytes. Of course, you can still send manually-crafted junk by passing a unibyte string. */ - char *val = SDATA (object); + char *val = SSDATA (object); XD_DEBUG_MESSAGE ("%c %s", dtype, val); if (!dbus_message_iter_append_basic (iter, dtype, &val)) XD_SIGNAL2 (build_string ("Unable to append argument"), object); @@ -569,7 +569,7 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) && STRINGP (CAR_SAFE (XD_NEXT_VALUE (object))) && NILP (CDR_SAFE (XD_NEXT_VALUE (object)))) { - strcpy (signature, SDATA (CAR_SAFE (XD_NEXT_VALUE (object)))); + strcpy (signature, SSDATA (CAR_SAFE (XD_NEXT_VALUE (object)))); object = CDR_SAFE (XD_NEXT_VALUE (object)); } @@ -789,7 +789,7 @@ xd_initialize (Lisp_Object bus, int raise_error) dbus_error_init (&derror); if (STRINGP (bus)) - connection = dbus_connection_open (SDATA (bus), &derror); + connection = dbus_connection_open (SSDATA (bus), &derror); else if (EQ (bus, QCdbus_system_bus)) connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror); @@ -1089,10 +1089,10 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI connection = xd_initialize (bus, TRUE); /* Create the message. */ - dmessage = dbus_message_new_method_call (SDATA (service), - SDATA (path), - SDATA (interface), - SDATA (method)); + dmessage = dbus_message_new_method_call (SSDATA (service), + SSDATA (path), + SSDATA (interface), + SSDATA (method)); UNGCPRO; if (dmessage == NULL) XD_SIGNAL1 (build_string ("Unable to create a new message")); @@ -1272,10 +1272,10 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE connection = xd_initialize (bus, TRUE); /* Create the message. */ - dmessage = dbus_message_new_method_call (SDATA (service), - SDATA (path), - SDATA (interface), - SDATA (method)); + dmessage = dbus_message_new_method_call (SSDATA (service), + SSDATA (path), + SSDATA (interface), + SSDATA (method)); if (dmessage == NULL) XD_SIGNAL1 (build_string ("Unable to create a new message")); @@ -1386,7 +1386,7 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); if ((dmessage == NULL) || (!dbus_message_set_reply_serial (dmessage, XUINT (serial))) - || (!dbus_message_set_destination (dmessage, SDATA (service)))) + || (!dbus_message_set_destination (dmessage, SSDATA (service)))) { UNGCPRO; XD_SIGNAL1 (build_string ("Unable to create a return message")); @@ -1475,7 +1475,7 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) if ((dmessage == NULL) || (!dbus_message_set_error_name (dmessage, DBUS_ERROR_FAILED)) || (!dbus_message_set_reply_serial (dmessage, XUINT (serial))) - || (!dbus_message_set_destination (dmessage, SDATA (service)))) + || (!dbus_message_set_destination (dmessage, SSDATA (service)))) { UNGCPRO; XD_SIGNAL1 (build_string ("Unable to create a error message")); @@ -1591,9 +1591,9 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) connection = xd_initialize (bus, TRUE); /* Create the message. */ - dmessage = dbus_message_new_signal (SDATA (path), - SDATA (interface), - SDATA (signal)); + dmessage = dbus_message_new_signal (SSDATA (path), + SSDATA (interface), + SSDATA (signal)); UNGCPRO; if (dmessage == NULL) XD_SIGNAL1 (build_string ("Unable to create a new message")); @@ -1745,11 +1745,11 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) /* key has the structure (UNAME SERVICE PATH HANDLER). */ if (((uname == NULL) || (NILP (CAR_SAFE (key))) - || (strcmp (uname, SDATA (CAR_SAFE (key))) == 0)) + || (strcmp (uname, SSDATA (CAR_SAFE (key))) == 0)) && ((path == NULL) || (NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (key))))) || (strcmp (path, - SDATA (CAR_SAFE (CDR_SAFE (CDR_SAFE (key))))) + SSDATA (CAR_SAFE (CDR_SAFE (CDR_SAFE (key))))) == 0)) && (!NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key))))))) { @@ -1921,7 +1921,7 @@ usage: (dbus-register-service BUS SERVICE &rest FLAGS) */) /* Request the known name from the bus. */ dbus_error_init (&derror); - result = dbus_bus_request_name (connection, SDATA (service), flags, + result = dbus_bus_request_name (connection, SSDATA (service), flags, &derror); if (dbus_error_is_set (&derror)) XD_ERROR (derror); @@ -2019,8 +2019,8 @@ usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARG name of "org.freedesktop.DBus" is that string itself. */ if ((STRINGP (service)) && (SBYTES (service) > 0) - && (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0) - && (strncmp (SDATA (service), ":", 1) != 0)) + && (strcmp (SSDATA (service), DBUS_SERVICE_DBUS) != 0) + && (strncmp (SSDATA (service), ":", 1) != 0)) { uname = call2 (intern ("dbus-get-name-owner"), bus, service); /* When there is no unique name, we mark it with an empty @@ -2350,4 +2350,3 @@ be called when the D-Bus reply message arrives. */); } #endif /* HAVE_DBUS */ - -- 2.20.1