See embedded comment below.

________________________________

From: Sasha Khapyorsky [mailto:[EMAIL PROTECTED]
Sent: Thu 11/16/2006 5:52 PM
To: Michael S. Tsirkin
Cc: Hal Rosenstock; [email protected]
Subject: Re: [PATCH 2/2] libibcommon: enable printf() style format strict 
checking



On 17:03 Thu 16 Nov     , Michael S. Tsirkin wrote:
> > 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.

This is not "the style" for this library,

<hnr> This is something I want to clean up by deprecating the non prefixed 
names. </hnr>

but I have nothing against adding prefix here. Will do.

> But anyway - why is this necessary?
> Does anyone actually try compiling libibcommon not in gcc? Why?

I don't know if anyone will want to build this with non-gcc compiler,
but I know that this attribute is gcc extension.

> And AFAIK e.g. intel compiler implements this __attribute__.

As well as format(printf(...))? It is nice. I don't have icc to check
this, but feel free to send the patch if you like.

Sasha

>
> >  /* 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



_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to