mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Betty Dall <betty.dall@hp.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: Add checks for do {} while (0) macro misuses
Date: Fri, 20 Jul 2012 14:40:46 +0000 (UTC)	[thread overview]
Message-ID: <loom.20120720T160308-562@post.gmane.org> (raw)
In-Reply-To: <1342735885.17350.3.camel@joe2Laptop>

Hi Joe,

Joe Perches <joe <at> perches.com> writes:

> 
> These types of macros should not be used for either a
> single statement nor should the macro end with a semi-colon.
> 
> Add tests for these conditions.
> 
> Signed-off-by: Joe Perches <joe <at> perches.com>
> ---
>  scripts/checkpatch.pl |   39 +++++++++++++++++++++++++++++++++++++++
>  1 files changed, 39 insertions(+), 0 deletions(-)


I reviewed this and tested it out on the qib.h file we were looking at yesterday 
and it worked well. I was worried about a nested do {} while(0), because it will 
match with the first while. Here is a test case:
#define qib_devinfo(pcidev, fmt, ...) \
        do { \
                do { \
                        dev_info(&(pcidev)->dev, fmt, ##__VA_ARGS__); \
                } while (0); \
        } while (0)

Checkpatch.pl didn't complain about that one. Granted, it is a contrived test 
case. Your change will catch the real problems.

-Betty




  reply	other threads:[~2012-07-20 14:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19 22:11 Joe Perches
2012-07-20 14:40 ` Betty Dall [this message]
2012-07-20 15:49   ` Joe Perches

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=loom.20120720T160308-562@post.gmane.org \
    --to=betty.dall@hp.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

all inboxes | Powered by JetHome®