diff mbox

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

Message ID 1389551659-18559-1-git-send-email-keithp@keithp.com
State New, archived
Headers show

Commit Message

Keith Packard Jan. 12, 2014, 6:34 p.m. UTC
the drmServerInfo member, debug_print, takes a printf format string
and varargs list. Tell the compiler about it.

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

Comments

Thierry Reding Jan. 13, 2014, 9:13 a.m. UTC | #1
On Sun, Jan 12, 2014 at 10:34:19AM -0800, Keith Packard wrote:
> the drmServerInfo member, debug_print, takes a printf format string
> and varargs list. Tell the compiler about it.
> 
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
>  xf86drm.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/xf86drm.h b/xf86drm.h
> index 1e763a3..5e170f8 100644
> --- a/xf86drm.h
> +++ b/xf86drm.h
> @@ -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;

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

Thierry
Keith Packard Jan. 13, 2014, 2:19 p.m. UTC | #2
Thierry Reding <thierry.reding@gmail.com> writes:

> 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!
Ian Romanick Jan. 13, 2014, 6:03 p.m. UTC | #3
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>

On 01/12/2014 10:34 AM, Keith Packard wrote:
> the drmServerInfo member, debug_print, takes a printf format string
> and varargs list. Tell the compiler about it.
> 
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
>  xf86drm.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/xf86drm.h b/xf86drm.h
> index 1e763a3..5e170f8 100644
> --- a/xf86drm.h
> +++ b/xf86drm.h
> @@ -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;
>
Keith Packard Jan. 13, 2014, 6:14 p.m. UTC | #4
Ian Romanick <idr@freedesktop.org> writes:

> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>

Thanks. Pushed.
   8279c8f..cb4bc8e  master -> master
diff mbox

Patch

diff --git a/xf86drm.h b/xf86drm.h
index 1e763a3..5e170f8 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -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;