aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Golaszewski <bgolaszewski@baylibre.com>2015-04-16 15:43:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-17 09:03:54 -0400
commitf2027543b9cb47e1853d8c34fe931e2fcee5cb65 (patch)
tree75f849fec3effd981186b501974ea7367d346f0d
parent95d119528b0b8440a63bc13904e9873fc3a70503 (diff)
documentation: update CodingStyle on local variables naming in macros
Describe proper naming convention for local variables in macros resembling functions. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--Documentation/CodingStyle13
1 files changed, 13 insertions, 0 deletions
diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
index 449a8a19fc21..4d4f06d47e06 100644
--- a/Documentation/CodingStyle
+++ b/Documentation/CodingStyle
@@ -659,6 +659,19 @@ macros using parameters.
659#define CONSTANT 0x4000 659#define CONSTANT 0x4000
660#define CONSTEXP (CONSTANT | 3) 660#define CONSTEXP (CONSTANT | 3)
661 661
6625) namespace collisions when defining local variables in macros resembling
663functions:
664
665#define FOO(x) \
666({ \
667 typeof(x) ret; \
668 ret = calc_ret(x); \
669 (ret); \
670)}
671
672ret is a common name for a local variable - __foo_ret is less likely
673to collide with an existing variable.
674
662The cpp manual deals with macros exhaustively. The gcc internals manual also 675The cpp manual deals with macros exhaustively. The gcc internals manual also
663covers RTL which is used frequently with assembly language in the kernel. 676covers RTL which is used frequently with assembly language in the kernel.
664 677