Skip to contentSkip to conversation

Mark debug_print with __attribute__ ((format(__printf__, 1, 0)))

PATCH In review Keith Packard 3 participants 5 messages Jan 12, 2014 – Jan 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Mark debug_print with __attribute__ ((format(__printf__, 1, 0)))

the drmServerInfo member, debug_print, takes a printf format string and varargs list. Tell the compiler about it.

---
 xf86drm.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
xf86drm.h +7 -1
index 1e763a3..5e170f8 100644
@@ -92,8 +92,14 @@ extern "C" {
 typedef unsigned int  drmSize,     *drmSizePtr;	    /**< For mapped regions */
 typedef void          *drmAddress, **drmAddressPtr; /**< For mapped regions */
 
+#if (__GNUC__ >= 3)
+#define DRM_PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
+#else
+#define DRM_PRINTFLIKE(f, a)
+#endif
+
 typedef struct _drmServerInfo {
-  int (*debug_print)(const char *format, va_list ap);
+  int (*debug_print)(const char *format, va_list ap) DRM_PRINTFLIKE(1,0);
   int (*load_module)(const char *name);
   void (*get_perms)(gid_t *, mode_t *);
 } drmServerInfo, *drmServerInfoPtr;
Signature · 1 line
1.8.5.2
#1 lore raw
Quoted 18 lines · Keith Packard

the drmServerInfo member, debug_print, takes a printf format string and varargs list. Tell the compiler about it.

---
 xf86drm.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
xf86drm.h +2 -0
index 1e763a3..5e170f8 100644
@@ -92,8 +92,14 @@ extern "C" {
 typedef unsigned int  drmSize,     *drmSizePtr;	    /**< For mapped regions */
 typedef void          *drmAddress, **drmAddressPtr; /**< For mapped regions */
 
+#if (__GNUC__ >= 3)
+#define DRM_PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))

xf86drm.h extern "C" { · line 105

Quoted 10 lines
xf86drm.h +5 -1
+#else
+#define DRM_PRINTFLIKE(f, a)
+#endif
+
 typedef struct _drmServerInfo {
-  int (*debug_print)(const char *format, va_list ap);
+  int (*debug_print)(const char *format, va_list ap) DRM_PRINTFLIKE(1,0);
   int (*load_module)(const char *name);
   void (*get_perms)(gid_t *, mode_t *);
 } drmServerInfo, *drmServerInfoPtr;

While at it, perhaps the drmMsg() and drmDebugPrint() functions should be similarily annotated as well?

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 2 lines · Thierry Reding

While at it, perhaps the drmMsg() and drmDebugPrint() functions should be similarily annotated as well?

I don't know; I'm just fixing X server warnings this week and this was the source of one of them. Additional warning fixes for drm would be a great idea!

Signature · 1 line
[email protected]

_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by on v1 1/1
#3 lore raw
In reply to Keith Packard
Quoted 29 lines · Keith Packard

the drmServerInfo member, debug_print, takes a printf format string and varargs list. Tell the compiler about it.

---
 xf86drm.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
xf86drm.h +7 -1
index 1e763a3..5e170f8 100644
@@ -92,8 +92,14 @@ extern "C" {
 typedef unsigned int  drmSize,     *drmSizePtr;	    /**< For mapped regions */
 typedef void          *drmAddress, **drmAddressPtr; /**< For mapped regions */
 
+#if (__GNUC__ >= 3)
+#define DRM_PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
+#else
+#define DRM_PRINTFLIKE(f, a)
+#endif
+
 typedef struct _drmServerInfo {
-  int (*debug_print)(const char *format, va_list ap);
+  int (*debug_print)(const char *format, va_list ap) DRM_PRINTFLIKE(1,0);
   int (*load_module)(const char *name);
   void (*get_perms)(gid_t *, mode_t *);
 } drmServerInfo, *drmServerInfoPtr;