[PATCH] Mark drmServerInfo.debug_print with printf attribute

Keith Packard keithp at keithp.com
Wed Dec 11 13:17:07 PST 2013


I stole the conditional for _X_ATTRIBUTE_PRINTF from xproto and
changed the name to _DRM_ATTRIBUTE_PRINTF to avoid future conflicts.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 xf86drm.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/xf86drm.h b/xf86drm.h
index 1e763a3..0bf205f 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -92,8 +92,15 @@ extern "C" {
 typedef unsigned int  drmSize,     *drmSizePtr;	    /**< For mapped regions */
 typedef void          *drmAddress, **drmAddressPtr; /**< For mapped regions */
 
+/* Added in X11R6.9, so available in any version of modular xproto */
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
+# define _DRM_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))
+#else /* not gcc >= 2.3 */
+# define _DRM_ATTRIBUTE_PRINTF(x,y)
+#endif
+
 typedef struct _drmServerInfo {
-  int (*debug_print)(const char *format, va_list ap);
+  int (*debug_print)(const char *format, va_list ap) _DRM_ATTRIBUTE_PRINTF(1,0);
   int (*load_module)(const char *name);
   void (*get_perms)(gid_t *, mode_t *);
 } drmServerInfo, *drmServerInfoPtr;
-- 
1.8.4.4



More information about the dri-devel mailing list