[PATCH] Fix gcc-4.5.2 "statement with no effect" warnings in UBIFS

Mike Frysinger vapier.adi at gmail.com
Mon Apr 11 20:49:53 EDT 2011


On Mon, Apr 11, 2011 at 18:36, Maksim Rayskiy wrote:
> On Mon, Apr 11, 2011 at 3:08 PM, Mike Frysinger wrote:
>> On Mon, Apr 11, 2011 at 17:50,  <maksim.rayskiy at gmail.com> wrote:
>>> From: Maksim Rayskiy <maksim.rayskiy at gmail.com>
>>>
>>> When compiling UBIFS with CONFIG_UBIFS_FS_DEBUG not set,
>>> gcc-4.5.2 generates a slew of "warning: statement with no effect"
>>> on references to non-void functions defined as 0.
>>> To avoid these warnings, change appropriate definitions from
>>>  #define dbg_xxx(a)     0
>>> to
>>>  #define dbg_xxx(a)     ({0; })
>>
>> we probably want to make these inline funcs.  otherwise we get
>> misbehavior if someone does something like:
>>    dbg_dump_index(c++);
>
> I agree that would be a problem, but if such calls existed, we would
> be dealing not with compiler warnings but with completely broken code.
> I think it is bad style to have side-effects in debug functions.

we are dealing with broken code.  people should not have to know about
the implementation of functions in order to safely use them.
-mike



More information about the linux-mtd mailing list