DBUS_GNUC_FORMAT

Olivier Andrieu oliv__a at users.sourceforge.net
Fri Oct 1 18:41:36 UTC 2004


Hi,

dbus_set_error uses a printf-like format string but does not have a
DBUS_GNUC_FORMAT in its prototype. The definition of DBUS_GNUC_*
macros has to be moved a bit for this to work.

OK to commit ?

-- 
   Olivier
-------------- next part --------------
Index: dbus-errors.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-errors.h,v
retrieving revision 1.26
diff -u -r1.26 dbus-errors.h
--- dbus-errors.h	9 Sep 2004 10:20:17 -0000	1.26
+++ dbus-errors.h	27 Sep 2004 21:47:52 -0000
@@ -57,7 +57,7 @@
 void        dbus_set_error       (DBusError       *error,
                                   const char      *name,
                                   const char      *message,
-                                  ...);
+                                  ...) _DBUS_GNUC_PRINTF (3, 4);
 void        dbus_set_error_const (DBusError       *error,
                                   const char      *name,
                                   const char      *message);
Index: dbus-macros.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-macros.h,v
retrieving revision 1.4
diff -u -r1.4 dbus-macros.h
--- dbus-macros.h	10 Aug 2004 03:06:59 -0000	1.4
+++ dbus-macros.h	27 Sep 2004 21:47:52 -0000
@@ -50,6 +50,22 @@
 #  endif /* !__cplusplus */
 #endif
 
+#if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define _DBUS_GNUC_PRINTF( format_idx, arg_idx )    \
+  __attribute__((__format__ (__printf__, format_idx, arg_idx)))
+#define _DBUS_GNUC_SCANF( format_idx, arg_idx )     \
+  __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
+#define _DBUS_GNUC_FORMAT( arg_idx )                \
+  __attribute__((__format_arg__ (arg_idx)))
+#define _DBUS_GNUC_NORETURN                         \
+  __attribute__((__noreturn__))
+#else   /* !__GNUC__ */
+#define _DBUS_GNUC_PRINTF( format_idx, arg_idx )
+#define _DBUS_GNUC_SCANF( format_idx, arg_idx )
+#define _DBUS_GNUC_FORMAT( arg_idx )
+#define _DBUS_GNUC_NORETURN
+#endif  /* !__GNUC__ */
+
 /* Normally docs are in .c files, but there isn't a .c file for this. */
 /**
  * @defgroup DBusMacros Utility macros
Index: dbus-message.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message.h,v
retrieving revision 1.55
diff -u -r1.55 dbus-message.h
--- dbus-message.h	9 Sep 2004 10:20:17 -0000	1.55
+++ dbus-message.h	27 Sep 2004 21:47:53 -0000
@@ -75,7 +75,7 @@
 DBusMessage* dbus_message_new_error_printf  (DBusMessage *reply_to,
                                              const char  *error_name,
                                              const char  *error_format,
-					     ...);
+					     ...) _DBUS_GNUC_PRINTF (3, 4);
 
 DBusMessage* dbus_message_copy              (const DBusMessage *message);
 
Index: dbus-sysdeps.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.c,v
retrieving revision 1.79
diff -u -r1.79 dbus-sysdeps.c
--- dbus-sysdeps.c	17 Sep 2004 09:14:49 -0000	1.79
+++ dbus-sysdeps.c	27 Sep 2004 21:47:58 -0000
@@ -2122,7 +2122,7 @@
     {
       dbus_set_error (error, DBUS_ERROR_FAILED,
                       "File size %lu of \"%s\" is too large.",
-                      filename_c, (unsigned long) sb.st_size);
+                      (unsigned long) sb.st_size, filename_c);
       close (fd);
       return FALSE;
     }
Index: dbus-sysdeps.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.h,v
retrieving revision 1.43
diff -u -r1.43 dbus-sysdeps.h
--- dbus-sysdeps.h	9 Sep 2004 10:20:17 -0000	1.43
+++ dbus-sysdeps.h	27 Sep 2004 21:47:58 -0000
@@ -50,22 +50,6 @@
 
 typedef struct DBusString DBusString;
 
-#if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-#define _DBUS_GNUC_PRINTF( format_idx, arg_idx )    \
-  __attribute__((__format__ (__printf__, format_idx, arg_idx)))
-#define _DBUS_GNUC_SCANF( format_idx, arg_idx )     \
-  __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
-#define _DBUS_GNUC_FORMAT( arg_idx )                \
-  __attribute__((__format_arg__ (arg_idx)))
-#define _DBUS_GNUC_NORETURN                         \
-  __attribute__((__noreturn__))
-#else   /* !__GNUC__ */
-#define _DBUS_GNUC_PRINTF( format_idx, arg_idx )
-#define _DBUS_GNUC_SCANF( format_idx, arg_idx )
-#define _DBUS_GNUC_FORMAT( arg_idx )
-#define _DBUS_GNUC_NORETURN
-#endif  /* !__GNUC__ */
-
 void _dbus_abort (void) _DBUS_GNUC_NORETURN;
 
 const char* _dbus_getenv (const char *varname);


More information about the dbus mailing list