lkml.org 
[lkml]   [2012]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: checkpatch.pl: Wrong check SINGLE_STATEMENT_DO_WHILE_MACRO
    On Thu, Aug 02, 2012 at 10:00:04AM +0200, Schrober wrote:
    > Hi,
    >
    > I think your check for SINGLE_STATEMENT_DO_WHILE_MACRO is wrong. Just to give
    > an example:
    >
    > #define foobar(x) \
    > do { \
    > if (pizza_ready(x)) \
    > eat_pizza(x); \
    > } while (0)
    >
    >
    > if (hungry(y))
    > foobar(x);
    > else
    > barfoo(x);
    >
    > checkpatch does now complain about something like "WARNING: Single statement
    > macros should not use a do {} while (0) loop"
    >
    > But we would have an ambiguous else when the do-while is removed. The code
    > works as expected with the do-while but the else is "attached" to the wrong
    > "if" when the do-while is removed.
    >
    > And yes, this example is made that easy to make it easy to understand. There
    > are examples were static inline code would not work very well (vararg for
    > example).
    >
    > Please fix or remove your check. Otherwise some people will be start to
    > overeagerly change these macros and break the kernel doing that.

    It does appear this check should not apply when a control statement is
    included.

    -apw


    \
     
     \ /
      Last update: 2012-08-02 17:01    [W:0.026 / U:78.952 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site