Re: [PATCH 1/1] Fix potentially dangerous trailing ';' in #definedvalues/expressions

From: Jiri Kosina
Date: Thu Jul 21 2011 - 08:10:44 EST


On Thu, 14 Jul 2011, Phil Carmody wrote:

> All these are instances of
> #define NAME value;
> or
> #define NAME(params_opt) value;
>
> These of course fail to build when used in contexts like
> if(foo $OP NAME)
> while(bar $OP NAME)
> and may silently generate the wrong code in contexts such as
> foo = NAME + 1; /* foo = value; + 1; */
> bar = NAME - 1; /* bar = value; - 1; */
> baz = NAME & quux; /* baz = value; & quux; */
>
> Reported on comp.lang.c,
> Message-ID: <ab0d55fe-25e5-482b-811e-c475aa6065c3@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
> Initial analysis of the dangers provided by Keith Thompson in that thread.
>
> There are many more instances of more complicated macros having unnecessary
> trailing semicolons, but this pile seems to be all of the cases of simple
> values suffering from the problem. (Thus things that are likely to be found
> in one of the contexts above, more complicated ones aren't.)
>
> Signed-off-by: Phil Carmody <ext-phil.2.carmody@xxxxxxxxx>

Applied, thanks.

--
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/