From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751849AbbCSXWk (ORCPT ); Thu, 19 Mar 2015 19:22:40 -0400 Received: from smtprelay0184.hostedemail.com ([216.40.44.184]:38345 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751810AbbCSXWi (ORCPT ); Thu, 19 Mar 2015 19:22:38 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1540:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:4321:5007:6261:8957:10004:10400:10848:11232:11658:11914:12517:12519:12679:12740:13069:13161:13229:13255:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: wave21_33d3b33a8880c X-Filterd-Recvd-Size: 1889 Message-ID: <1426807355.21142.21.camel@perches.com> Subject: Re: [PATCH v4 2/5] documentation: update CodingStyle on local variables naming in macros From: Joe Perches To: Bartosz Golaszewski Cc: LKML , Guenter Roeck , lm-sensors , Andrew Morton , Steven Rostedt Date: Thu, 19 Mar 2015 16:22:35 -0700 In-Reply-To: <1426786065-9798-3-git-send-email-bgolaszewski@baylibre.com> References: <1426786065-9798-1-git-send-email-bgolaszewski@baylibre.com> <1426786065-9798-3-git-send-email-bgolaszewski@baylibre.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.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 Thu, 2015-03-19 at 18:27 +0100, Bartosz Golaszewski wrote: > Describe proper naming convention for local variables in macros > resembling functions. [] > diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle [] > +5) namespace collisions when defining local variables in macros resembling > +functions: > + > +#define FOO(x) \ > +({ \ > + typeof(x) ret; \ > + ret = calc_ret(x); \ > + (ret); \ trivia: ret wouldn't need parentheses here. > +)} > + > +ret is a common name for a local variable - __foo_ret is less likely > +to collide with an existing variable. Is shadowing really much of a problem here? These are statement expression macros and names have local scope anyway. It's similar to function arguments using the same names as parameters.