Skip to contentSkip to conversation

Mark drmServerInfo.debug_print with printf attribute

PATCH In review Keith Packard 2 participants 3 messages Dec 11, 2013 – Dec 12, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Mark drmServerInfo.debug_print with printf attribute

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

---
 xf86drm.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
xf86drm.h +8 -1
index 1e763a3..0bf205f 100644
@@ -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;
Signature · 1 line
1.8.4.4
#1 lore raw
Quoted 13 lines · Keith Packard

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

---
  xf86drm.h | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)
xf86drm.h +0 -0
index 1e763a3..0bf205f 100644

xf86drm.h extern "C" { · line 95

Quoted 4 lines
xf86drm.h +1 -0
@@ -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 */

You should drop that line - those comments are used for us to figure out which
xproto version to list in the pkg-config requirements when using newer _X_* macros out of Xfuncproto.h, so doesn't make sense here.

Also be warned that using a macro name starting with an _ will cause you to get complaints about violating the "reserved for the implementation" rule in the ANSI/ISO C standards from people who consider the implementation to solely be the compiler, not the OS. https://bugs.freedesktop.org/show_bug.cgi?id=70686
for example.

Signature · 2 lines
	-Alan Coopersmith-              [email protected]
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
#2 lore raw
Quoted 9 lines · Alan Coopersmith

You should drop that line - those comments are used for us to figure out which xproto version to list in the pkg-config requirements when using newer _X_* macros out of Xfuncproto.h, so doesn't make sense here.

Also be warned that using a macro name starting with an _ will cause you to get complaints about violating the "reserved for the implementation" rule in the ANSI/ISO C standards from people who consider the implementation to solely be the compiler, not the OS. https://bugs.freedesktop.org/show_bug.cgi?id=70686
for example.

Thanks for the suggestions; both easy to adopt.

Signature · 1 line
[email protected]

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