[sane-devel] [patch] use of gcc format attribute
Frank Zago
fzago at greshamstorage.com
Wed Feb 13 22:11:27 GMT 2002
This patch allow to detect errors in DBG macros format.
eg:
DBG (1,
"sane_open: device %s not found, trying to register it
anyway\n");
gives --> net.c:759: warning: too few arguments for format
It also detect where %x is used instead of %p. And so on.
Frank.
-------------- next part --------------
--- sane-backends-1.0.7.org/include/sane/sanei_debug.h Tue Nov 8 01:32:54 1994
+++ sane-sceptre-1.0.7/include/sane/sanei_debug.h Wed Feb 13 15:24:00 2002
@@ -56,7 +56,11 @@
# ifdef DEBUG_DECLARE_ONLY
-extern void DBG_LOCAL (int level, const char *msg, ...);
+extern void DBG_LOCAL (int level, const char *msg, ...)
+#ifdef __GNUC__
+__attribute__ ((format (printf, 2, 3)))
+#endif
+;
# else /* !DEBUG_DECLARE_ONLY */
@@ -64,6 +68,13 @@
extern void sanei_debug_msg
(int level, int max_level, const char *be, const char *fmt, va_list ap);
+
+#ifdef __GNUC__
+# ifndef DEBUG_NOT_STATIC
+static
+# endif /* !DEBUG_NOT_STATIC */
+void DBG_LOCAL (int level, const char *msg, ...) __attribute__ ((format (printf, 2, 3)));
+#endif /* __GNUC__ */
# ifndef DEBUG_NOT_STATIC
static
More information about the sane-devel
mailing list