On Tue, Apr 02, 2019 at 10:05:00AM +0300, Gal Pressman wrote: > >>>> +#elif defined(DEBUG) > >>>> +#define ibdev_dbg(__dev, format, args...) \ > >>>> + ibdev_printk(KERN_DEBUG, __dev, format, ##args) > >>>> +#else > >>>> +#define ibdev_dbg(__dev, format, args...) \ > >>>> +({ \ > >>>> + if (0) \ > >>> > >>> Why isn't "empty macro" enough here and we need "if (0)"? > >> > >> I was wondering as well :). > >> This is copied from the netdev_dbg counterpart, my best guess is some kind of > >> compilation checks in case debug is disabled but I can't even convince myself.. > > > > It is a trick to get the compiler to do a format & type check even > > when debug is disabled. > > > > Personally I prefer the much clearer non #define version > > > > __printf(2, 3) > > static inline void ibdev_dbg(const struct ib_device *dev, const char > > *format, ...) {} > > > > Instead of the macro tricks. > > Wouldn't that lose the format type checking? For example passing a pointer to %d? No, the static inline has the __printf attribute so the compiler checks it even though the inline is empty Jason