BUILD_BUG_ON_ZERO -> BUILD_BUG_OR_ZERO
PATCH 1/1 BUILD_BUG_ON_ZERO -> BUILD_BUG_OR_ZERO
BUILD_BUG_ON_ZERO is named perfectly wrong, and BUILD_BUG_ON_RETURN_ZERO is too long. Flip three bits, and the name is much more suitable.
include/linux/compiler-gcc.h +1 -1
@@ -24,7 +24,7 @@/* &a[0] degrades to a pointer: a different type from an array */ #define __must_be_array (a) \ - BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) + BUILD_BUG_OR_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))#define inline inline __attribute__((always_inline))#define __inline__ __inline__ __attribute__((always_inline))
include/linux/kernel.h +1 -1
@@ -341,7 +341,7 @@ struct sysinfo {result (of value 0 and type size_t), so the expression can be used e.g. in a structure initializer (or where-ever else comma expressions aren't permitted). */ -#define BUILD_BUG_ON_ZERO (e) (sizeof(char[1 - 2 * !!(e)]) - 1) +#define BUILD_BUG_OR_ZERO (e) (sizeof(char[1 - 2 * !!(e)]) - 1)/* Trap pasters of __FUNCTION__ at compile-time */ #define __FUNCTION__ (__func__)
include/linux/moduleparam.h +1 -1
@@ -65,7 +65,7 @@ struct kparam_array#define __module_param_call (prefix, name, set, get, arg, perm) \/* Default value instead of permissions? */ \ static int __param_perm_check_##name __attribute__((unused)) = \ - BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ + BUILD_BUG_OR_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ static char __param_str_##name[] = prefix #name; \ static struct kernel_param const __param_##name \ __attribute_used__ \
I have to admit that I don't see the point here - I can't seem to make any sense of the OR... Jan
Quoted 1 line
Quoted 1 line
Quoted 1 line
Rusty Russell <[email protected]> 12.03.07 00:28 >>>
BUILD_BUG_ON_ZERO is named perfectly wrong, and BUILD_BUG_ON_RETURN_ZERO is too long. Flip three bits, and the name is much more suitable.
include/linux/compiler-gcc.h +1 -1
@@ -24,7 +24,7 @@/* &a[0] degrades to a pointer: a different type from an array */ #define __must_be_array (a) \ - BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) + BUILD_BUG_OR_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))#define inline inline __attribute__((always_inline))#define __inline__ __inline__ __attribute__((always_inline))
include/linux/kernel.h +1 -1
@@ -341,7 +341,7 @@ struct sysinfo {result (of value 0 and type size_t), so the expression can be used e.g. in a structure initializer (or where-ever else comma expressions aren't permitted). */ -#define BUILD_BUG_ON_ZERO (e) (sizeof(char[1 - 2 * !!(e)]) - 1) +#define BUILD_BUG_OR_ZERO (e) (sizeof(char[1 - 2 * !!(e)]) - 1)/* Trap pasters of __FUNCTION__ at compile-time */ #define __FUNCTION__ (__func__)
include/linux/moduleparam.h +1 -1
@@ -65,7 +65,7 @@ struct kparam_array#define __module_param_call (prefix, name, set, get, arg, perm) \/* Default value instead of permissions? */ \ static int __param_perm_check_##name __attribute__((unused)) = \ - BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ + BUILD_BUG_OR_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ static char __param_str_##name[] = prefix #name; \ static struct kernel_param const __param_##name \ __attribute_used__ \
Quoted 3 lines · Jan Beulich
I have to admit that I don't see the point here - I can't seem to make any sense of the OR... Jan
BUILD_BUG_OR_ZERO will either (a) result in a build bug or (b) the number zero, suitable for arithmetic.
Quoted 45 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Rusty Russell <[email protected]> 12.03.07 00:28 >>>
BUILD_BUG_ON_ZEROis named perfectly wrong, andBUILD_BUG_ON_RETURN_ZEROis too long. Flip three bits, and the name is much more suitable.Signed-off-by Rusty Russell <[email protected]>diff -r
6fb745a5bb51include/linux/compiler-gcc.hinclude/linux/compiler-gcc.h +1
-1@@ -24,7 +24,7 @@/* &a[0] degrades to a pointer: a different type from an array */ #define __must_be_array (a) \ - BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) + BUILD_BUG_OR_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))#define inline inline __attribute__((always_inline))#define __inline__ __inline__ __attribute__((always_inline))diff -r
6fb745a5bb51include/linux/kernel.hinclude/linux/kernel.h +1
-1@@ -341,7 +341,7 @@ struct sysinfo {result (of value 0 and type size_t), so the expression can be used e.g. in a structure initializer (or where-ever else comma expressions aren't permitted). */ -#define BUILD_BUG_ON_ZERO (e) (sizeof(char[1 - 2 * !!(e)]) - 1) +#define BUILD_BUG_OR_ZERO (e) (sizeof(char[1 - 2 * !!(e)]) - 1)/* Trap pasters of __FUNCTION__ at compile-time */ #define __FUNCTION__ (__func__)diff -r
6fb745a5bb51include/linux/moduleparam.hinclude/linux/moduleparam.h +1
-2@@ -65,7 +65,7 @@ struct kparam_array#define __module_param_call (prefix, name, set, get, arg, perm) \/* Default value instead of permissions? */ \ static int __param_perm_check_##name __attribute__((unused)) = \ - BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ + BUILD_BUG_OR_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ static char __param_str_##name[] = prefix #name; \ static struct kernel_param const __param_##name \ __attribute_used__ \ -
Quoted 5 lines
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Jan
Quoted 2 lines · Jan Beulich
I have to admit that I don't see the point here - I can't seem to make any sense of the OR... Jan
At least one other person thought that:
#define BUILD_BUG_ON_ZERO(e) BUILD_BUG_ON((e) == 0)
OTOH, BUILD_BUG_OR_ZERO says what happens: either it's a build bug, or it's zero.
Hope that clarifies,
Rusty.
Quoted 10 lines · Rusty Russell
Quoted 2 lines · Jan Beulich
I have to admit that I don't see the point here - I can't seem to make any sense of the OR... Jan
At least one other person thought that:
#define BUILD_BUG_ON_ZERO(e) BUILD_BUG_ON((e) == 0)OTOH,
BUILD_BUG_OR_ZEROsays what happens: either it's a build bug, or it's zero.
What about ZERO_UNLESS_BUILD_BUG_ON(e)? It's long though...
Signature · 3 lines
Stefan Richter -=====-=-=== --== -==-- http://arcgraph.de/sr/
Quoted 5 lines · Stefan Richter
Quoted 4 lines · Rusty Russell
Quoted 2 lines · Jan Beulich
I have to admit that I don't see the point here - I can't seem to make any sense of the OR... Jan
Quoted 8 lines
Quoted 6 lines
At least one other person thought that:
#define BUILD_BUG_ON_ZERO(e) BUILD_BUG_ON((e) == 0)OTOH,
BUILD_BUG_OR_ZEROsays what happens: either it's a build bug, or it's zero.What about
ZERO_UNLESS_BUILD_BUG_ON(e)? It's long though...
how often is this going to be used? it's not like the tree is currently awash in calls to BUILD_BUG_ON_ZERO as it is.
rday
Signature · 7 lines
======================================================================== Robert P. J. Day Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA http://fsdev.net/wiki/index.php?title=Main_Page ========================================================================
Quoted 9 lines · Robert P. J. Day
Quoted 5 lines · Stefan Richter
Quoted 2 lines · Rusty Russell
OTOH,
BUILD_BUG_OR_ZEROsays what happens: either it's a build bug, or it's zero.What about
ZERO_UNLESS_BUILD_BUG_ON(e)? It's long though...how often is this going to be used? it's not like the tree is currently awash in calls to
BUILD_BUG_ON_ZEROas it is.
Most of the time it will hidden as a macro-in-a-macro, like in ARRAY_SIZE(). So the length of the name doesn't matter much. But then, the _name_ itself doesn't matter much because authors of public macros are the primary user group, not John Driverhacker.
Signature · 3 lines
Stefan Richter -=====-=-=== --== -==-- http://arcgraph.de/sr/
Quoted 8 lines · Stefan Richter
Quoted 7 lines · Robert P. J. Day
Quoted 5 lines · Stefan Richter
Quoted 2 lines · Rusty Russell
OTOH,
BUILD_BUG_OR_ZEROsays what happens: either it's a build bug, or it's zero.What about
ZERO_UNLESS_BUILD_BUG_ON(e)? It's long though...
Quoted 7 lines
Quoted 2 lines
how often is this going to be used? it's not like the tree is currently awash in calls to
BUILD_BUG_ON_ZEROas it is.Most of the time it will hidden as a macro-in-a-macro, like in
ARRAY_SIZE(). So the length of the name doesn't matter much. But then, the _name_ itself doesn't matter much because authors of public macros are the primary user group, not John Driverhacker.
Well, there's a four line comment above it, so *someone* thought it worth documenting. Even if the new name isn't great, the old name is actively misleading. That's a 13, and we could be a 4.
http://ozlabs.org/~rusty/ols-2003-keynote/img52.html
Cheers,
Rusty.
Quoted 2 lines · Rusty Russell
BUILD_BUG_ON_ZEROis named perfectly wrong, andBUILD_BUG_ON_RETURN_ZEROis too long. Flip three bits, and the name is much more suitable.
Ok for me.
-Andi