From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965057AbbCSR3p (ORCPT ); Thu, 19 Mar 2015 13:29:45 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:33352 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754922AbbCSR10 (ORCPT ); Thu, 19 Mar 2015 13:27:26 -0400 From: Bartosz Golaszewski To: LKML Cc: Guenter Roeck , lm-sensors , Andrew Morton , Steven Rostedt , Bartosz Golaszewski Subject: [PATCH v4 2/5] documentation: update CodingStyle on local variables naming in macros Date: Thu, 19 Mar 2015 18:27:42 +0100 Message-Id: <1426786065-9798-3-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1426786065-9798-1-git-send-email-bgolaszewski@baylibre.com> References: <1426786065-9798-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Describe proper naming convention for local variables in macros resembling functions. Signed-off-by: Bartosz Golaszewski --- Documentation/CodingStyle | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle index 449a8a1..4d4f06d 100644 --- a/Documentation/CodingStyle +++ b/Documentation/CodingStyle @@ -659,6 +659,19 @@ macros using parameters. #define CONSTANT 0x4000 #define CONSTEXP (CONSTANT | 3) +5) namespace collisions when defining local variables in macros resembling +functions: + +#define FOO(x) \ +({ \ + typeof(x) ret; \ + ret = calc_ret(x); \ + (ret); \ +)} + +ret is a common name for a local variable - __foo_ret is less likely +to collide with an existing variable. + The cpp manual deals with macros exhaustively. The gcc internals manual also covers RTL which is used frequently with assembly language in the kernel. -- 2.1.4