gcc has the capability to check arguments on printf() like functions. The patch below adds this ability to chprintf() when using gcc. As chprintf() doesn't support the full printf() format, it won't catch everything, but it will warn if you pass an int type for a '%s', have too many/few arguments, etc ...
Code: Select all
Index: os/various/chprintf.h
===================================================================
--- os/various/chprintf.h (revision 865)
+++ os/various/chprintf.h (working copy)
@@ -39,7 +39,11 @@
#ifdef __cplusplus
extern "C" {
#endif
+#ifdef __GNUC__
+ void chprintf(BaseChannel *chp, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
+#else
void chprintf(BaseChannel *chp, const char *fmt, ...);
+#endif
#ifdef __cplusplus
}
#endif
Eric