Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bartosz Golaszewski and committed by
Linus Torvalds
f2027543 95d11952

+13
+13
Documentation/CodingStyle
··· 659 659 #define CONSTANT 0x4000 660 660 #define CONSTEXP (CONSTANT | 3) 661 661 662 + 5) namespace collisions when defining local variables in macros resembling 663 + functions: 664 + 665 + #define FOO(x) \ 666 + ({ \ 667 + typeof(x) ret; \ 668 + ret = calc_ret(x); \ 669 + (ret); \ 670 + )} 671 + 672 + ret is a common name for a local variable - __foo_ret is less likely 673 + to collide with an existing variable. 674 + 662 675 The cpp manual deals with macros exhaustively. The gcc internals manual also 663 676 covers RTL which is used frequently with assembly language in the kernel. 664 677