All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm] Mark functions printf-like where possible
@ 2014-02-19 15:42 Thierry Reding
  2014-02-19 19:32 ` Eric Anholt
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2014-02-19 15:42 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

These functions all take a format string and either a list of variable
arguments or a va_list. Use the new DRM_PRINTFLIKE macro to tell the
compiler about it so that the arguments can be checked against the
format string.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 intel/intel_decode.c |  7 ++-----
 tests/drmstat.c      |  2 +-
 xf86drm.c            | 10 +++++++---
 xf86drm.h            |  2 +-
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/intel/intel_decode.c b/intel/intel_decode.c
index c0a0cafc904e..61239dd96d27 100644
--- a/intel/intel_decode.c
+++ b/intel/intel_decode.c
@@ -29,6 +29,7 @@
 #include <stdarg.h>
 #include <string.h>
 
+#include "xf86drm.h"
 #include "intel_chipset.h"
 #include "intel_bufmgr.h"
 
@@ -104,11 +105,7 @@ static float int_as_float(uint32_t intval)
 	return uval.f;
 }
 
-static void
-instr_out(struct drm_intel_decode *ctx, unsigned int index,
-	  const char *fmt, ...) __attribute__((format(__printf__, 3, 4)));
-
-static void
+static void DRM_PRINTFLIKE(3, 4)
 instr_out(struct drm_intel_decode *ctx, unsigned int index,
 	  const char *fmt, ...)
 {
diff --git a/tests/drmstat.c b/tests/drmstat.c
index 345b8d2cda31..c51cbc6c9f61 100644
--- a/tests/drmstat.c
+++ b/tests/drmstat.c
@@ -425,7 +425,7 @@ int main(int argc, char **argv)
     return r; 
 }
 
-void
+void DRM_PRINTFLIKE(4, 0)
 xf86VDrvMsgVerb(int scrnIndex, int type, int verb, const char *format,
                 va_list args)
 {
diff --git a/xf86drm.c b/xf86drm.c
index 720952ff2cbd..fa5701abae51 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -104,12 +104,16 @@ void drmSetServerInfo(drmServerInfoPtr info)
  * This function is a wrapper around vfprintf().
  */
 
-static int drmDebugPrint(const char *format, va_list ap)
+static int DRM_PRINTFLIKE(1, 0)
+drmDebugPrint(const char *format, va_list ap)
 {
     return vfprintf(stderr, format, ap);
 }
 
-static int (*drm_debug_print)(const char *format, va_list ap) = drmDebugPrint;
+typedef int DRM_PRINTFLIKE(1, 0) (*debug_msg_func_t)(const char *format,
+						     va_list ap);
+
+static debug_msg_func_t drm_debug_print = drmDebugPrint;
 
 void
 drmMsg(const char *format, ...)
@@ -129,7 +133,7 @@ drmMsg(const char *format, ...)
 }
 
 void
-drmSetDebugMsgFunction(int (*debug_msg_ptr)(const char *format, va_list ap))
+drmSetDebugMsgFunction(debug_msg_func_t debug_msg_ptr)
 {
     drm_debug_print = debug_msg_ptr;
 }
diff --git a/xf86drm.h b/xf86drm.h
index 5e170f86fe5e..c024cc446354 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -704,7 +704,7 @@ extern int  drmSLLookupNeighbors(void *l, unsigned long key,
 
 extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened);
 extern void drmCloseOnce(int fd);
-extern void drmMsg(const char *format, ...);
+extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2);
 
 extern int drmSetMaster(int fd);
 extern int drmDropMaster(int fd);
-- 
1.8.4.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH libdrm] Mark functions printf-like where possible
  2014-02-19 15:42 [PATCH libdrm] Mark functions printf-like where possible Thierry Reding
@ 2014-02-19 19:32 ` Eric Anholt
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Anholt @ 2014-02-19 19:32 UTC (permalink / raw)
  To: Thierry Reding, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 371 bytes --]

Thierry Reding <thierry.reding@gmail.com> writes:

> From: Thierry Reding <treding@nvidia.com>
>
> These functions all take a format string and either a list of variable
> arguments or a va_list. Use the new DRM_PRINTFLIKE macro to tell the
> compiler about it so that the arguments can be checked against the
> format string.

Reviewed-by: Eric Anholt <eric@anholt.net>

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-19 19:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-19 15:42 [PATCH libdrm] Mark functions printf-like where possible Thierry Reding
2014-02-19 19:32 ` Eric Anholt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.