From: Schrober <franzschrober@yahoo.de>
To: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>, linux-kernel@vger.kernel.org
Subject: checkpatch.pl: Wrong check SINGLE_STATEMENT_DO_WHILE_MACRO
Date: Thu, 02 Aug 2012 10:00:04 +0200 [thread overview]
Message-ID: <4204029.7cYAuJfu4T@bentobox> (raw)
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.
--
Franz Schrober
next reply other threads:[~2012-08-02 8:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-02 8:00 Schrober [this message]
2012-08-02 14:20 ` checkpatch.pl: Wrong check SINGLE_STATEMENT_DO_WHILE_MACRO Andy Whitcroft
2012-08-02 15:26 ` [PATCH] checkpatch: Add control statement test to SINGLE_STATEMENT_DO_WHILE_MACRO Joe Perches
2012-08-02 16:23 ` Andy Whitcroft
2012-08-02 16:44 ` Schrober
2012-08-02 22:10 ` Stephen Rothwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4204029.7cYAuJfu4T@bentobox \
--to=franzschrober@yahoo.de \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).