Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1619348

Re: [bug report] checkpatch: if statement does not need to be enclosed in parentheses

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [bug report] checkpatch: if statement does not need to be enclosed in parentheses
Date 2017-04-08 19:40 +0200
Message-ID <tu2v7-8fQ-1@gated-at.bofh.it> (permalink)
References <tu161-7uL-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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);
 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[bug report] checkpatch: if statement does not need to be enclosed  in parentheses Alfonso Lima <alfonsolimaastor@gmail.com> - 2017-04-08 18:10 +0200
  Re: [bug report] checkpatch: if statement does not need to be  enclosed in parentheses Joe Perches <joe@perches.com> - 2017-04-08 19:40 +0200
    Re: [bug report] checkpatch: if statement does not need to be  enclosed in parentheses Andreas Mohr <andi@lisas.de> - 2017-04-09 11:10 +0200
      Re: [PATCH 2/2] checkpatch: Improve  MULTISTATEMENT_MACRO_USE_DO_WHILE test Joe Perches <joe@perches.com> - 2017-04-09 19:50 +0200
      [PATCH 1/2] checkpatch: Clarify the EMBEDDED_FUNCTION_NAME message Joe Perches <joe@perches.com> - 2017-04-09 19:50 +0200

csiph-web