[openib-general] [PATCH 2/2] libibcommon: enable printf() style format strict checking
Michael S. Tsirkin
mst at mellanox.co.il
Thu Nov 16 07:03:33 PST 2006
> diff --git a/libibcommon/include/infiniband/common.h b/libibcommon/include/infiniband/common.h
> index 83c0679..66afab0 100644
> --- a/libibcommon/include/infiniband/common.h
> +++ b/libibcommon/include/infiniband/common.h
> @@ -114,11 +114,16 @@ #endif
> #define ENUM_STR_DEF(enumname, last, val) (((unsigned)(val) < last) ? enumname ## _str[val] : "???")
> #define ENUM_STR_ARRAY(name) char * name ## _str[]
>
> +#ifdef __GNUC__
> +#define STRICT_FORMAT __attribute__((format(printf, 2, 3)))
> +#else
> +#define STRICT_FORMAT
> +#endif
You are polluting the global namespace - macros must be prefixed with
library name.
But anyway - why is this necessary?
Does anyone actually try compiling libibcommon not in gcc? Why?
And AFAIK e.g. intel compiler implements this __attribute__.
> /* util.c: debugging and tracing */
> -void ibwarn(const char * const fn, char *msg, ...);
> -void ibpanic(const char * const fn, char *msg, ...);
> -void logmsg(const char *const fn, char *msg, ...);
> +void ibwarn(const char * const fn, char *msg, ...) STRICT_FORMAT;
> +void ibpanic(const char * const fn, char *msg, ...) STRICT_FORMAT;
> +void logmsg(const char *const fn, char *msg, ...) STRICT_FORMAT;
>
> void xdump(FILE *file, char *msg, void *p, int size);
--
MST
More information about the general
mailing list