From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbdDHRds (ORCPT ); Sat, 8 Apr 2017 13:33:48 -0400 Received: from smtprelay0176.hostedemail.com ([216.40.44.176]:42821 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751517AbdDHRd1 (ORCPT ); Sat, 8 Apr 2017 13:33:27 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1539:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:2909:3138:3139:3140:3141:3142:3352:3622:3865:3866:3868:3870:3871:3872:3873:4184:4321:5007:10004:10400:10848:11232:11658:11914:12740:12760:12895:13069:13255:13311:13357:13439:14180:14181:14659:14721:21060:21080:21451:30012:30016:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: stone27_75080e293b263 X-Filterd-Recvd-Size: 1522 Message-ID: <1491672799.3250.41.camel@perches.com> Subject: Re: [bug report] checkpatch: if statement does not need to be enclosed in parentheses From: Joe Perches To: Alfonso Lima , apw@canonical.com Cc: linux-kernel@vger.kernel.org Date: Sat, 08 Apr 2017 10:33:19 -0700 In-Reply-To: <20170408160717.GA7337@alima-W65-67SF> References: <20170408160717.GA7337@alima-W65-67SF> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.3-0ubuntu0.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);