Re: [RFC PATCH 0/2] check for identical exprs on LHS and RHS of '&&'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 10, 2011 at 06:46:15PM +0100, Al Viro wrote:
> On Wed, Aug 10, 2011 at 10:44:23AM -0700, Josh Triplett wrote:
> 
> > How about checking for the same expression multiple times in a single
> > block of | or & expressions?  (flag1 | flag2 | flag2) seems like a
> > likely copy/paste error.
> 
> ... or result of macro expansion.

In Smatch, we store where all the macros are when we run the
preprocessor.  Then for some checks we check if there was a macro at
&expr->pos to see if it's inside a macro, and if so then the error is
suppressed.

For example, Smatch prints an error if you dereference a variable and
then later check it for NULL.  But if the check is inside a macro the
error gets suppressed.

    foo->bar;
    if (foo) { ...  <-- most likely an error.

    foo->bar;
    some_macro_that_checks_for_null(foo);  <-- not an error.

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux