All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Alfonso Lima <alfonsolimaastor@gmail.com>, apw@canonical.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [bug report] checkpatch: if statement does not need to be enclosed in parentheses
Date: Sat, 08 Apr 2017 10:33:19 -0700	[thread overview]
Message-ID: <1491672799.3250.41.camel@perches.com> (raw)
In-Reply-To: <20170408160717.GA7337@alima-W65-67SF>

On Sat, 2017-04-08 at 17:07 +0100, Alfonso Lima wrote:
> Hi,
> 
> In current linux-next, if you run the script on this piece of
> code:
> 
> #define FOO(a)				\
> 	if (a) {			\
> 		something();		\
> 		something_else();	\
> 	}
> 
> You should get:
> 
> ERROR: Macros with complex values should be enclosed in parentheses
> #1: FILE: foo.c:1:
> +#define FOO(a)				\
> +	if (a) {			\
> +		something();		\
> +		something_else();	\
> +	}
> 
> We could silence checkpatch.pl using "do {} while ()" around the
> if statement. However, the "if () {}" statement should be
> enough. If someone could confirm this, I'll go and fix it.

Multiple if/else use is the reason do {} while (0) is suggested.

	if (bar())
		FOO(a);
	else
		baz(b);
 

  reply	other threads:[~2017-04-08 17:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-08 16:07 [bug report] checkpatch: if statement does not need to be enclosed in parentheses Alfonso Lima
2017-04-08 17:33 ` Joe Perches [this message]
2017-04-09  8:55   ` Andreas Mohr
2017-04-09 17:45     ` [PATCH 1/2] checkpatch: Clarify the EMBEDDED_FUNCTION_NAME message Joe Perches
2017-04-09 17:45       ` [PATCH 2/2] checkpatch: Improve MULTISTATEMENT_MACRO_USE_DO_WHILE test Joe Perches
2017-04-09 17:46         ` Joe Perches
2017-04-09 17:59         ` [PATCH V2] " Joe Perches
2017-04-10  0:28           ` [PATCH V3] " 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=1491672799.3250.41.camel@perches.com \
    --to=joe@perches.com \
    --cc=alfonsolimaastor@gmail.com \
    --cc=apw@canonical.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.