Introduce U16_MAX and U32_MAX
Subsystems (4)
PATCH 27/28 Introduce U16_MAX and U32_MAX
From: Satyam Sharma <[email protected]>
... in kernel.h and clean up home-grown macros elsewhere in the tree.
Leave out the one in reiserfs_fs.h as it is in the userspace-visible part of that header. Still, #undef the (equivalent) kernel version there to avoid seeing "redefined, previous definition was here" gcc warnings.
---
drivers/net/netconsole.c | 7 +++---- include/linux/kernel.h | 3 +++ include/linux/reiserfs_fs.h | 1 + net/ipv4/tcp_illinois.c | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/netconsole.c renamed from drivers/net/netconsole.c~introduce-u16_max-and-u32_max +3 -4
@@ -34,6 +34,7 @@* ****************************************************************/ +#include <linux/kernel.h> #include <linux/mm.h> #include <linux/init.h> #include <linux/module.h>
@@ -389,7 +390,6 @@ static ssize_t store_local_port(struct n size_t count) {long local_port; -#define __U16_MAX ((__u16) ~0U)if (nt->enabled) { printk(KERN_ERR "netconsole: target (%s) is enabled, "
@@ -398,7 +398,7 @@ static ssize_t store_local_port(struct nreturn -EINVAL ; } - local_port =strtol10_check_range (buf,0 , __U16_MAX); + local_port =strtol10_check_range (buf,0 ,U16_MAX );if (local_port <0 )return local_port;
@@ -412,7 +412,6 @@ static ssize_t store_remote_port(struct size_t count) {long remote_port; -#define __U16_MAX ((__u16) ~0U)if (nt->enabled) { printk(KERN_ERR "netconsole: target (%s) is enabled, "
@@ -421,7 +420,7 @@ static ssize_t store_remote_port(structreturn -EINVAL ; } - remote_port =strtol10_check_range (buf,0 , __U16_MAX); + remote_port =strtol10_check_range (buf,0 ,U16_MAX );if (remote_port <0 )return remote_port;
include/linux/kernel.h renamed from include/linux/kernel.h~introduce-u16_max-and-u32_max +3 -0
@@ -30,6 +30,9 @@ extern const char linux_proc_banner[];#define LLONG_MIN (-LLONG_MAX - 1)#define ULLONG_MAX (~0ULL) +#define U16_MAX (0xffff) +#define U32_MAX (0xffffffff) +#define STACK_MAGIC 0xdeadbeef#define ALIGN (x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
include/linux/reiserfs_fs.h renamed from include/linux/reiserfs_fs.h~introduce-u16_max-and-u32_max +1 -0
@@ -1225,6 +1225,7 @@ struct treepath var = {.path_length = IL#define MAX_US_INT 0xffff// reiserfs version 2 has max offset 60 bits. Version 1 - 32 bit offset +#undef U32_MAX#define U32_MAX (~(__u32)0)static inline loff_t max_reiserfs_offset (struct inode *inode)
net/ipv4/tcp_illinois.c renamed from net/ipv4/tcp_illinois.c~introduce-u16_max-and-u32_max +1 -1
@@ -12,6 +12,7 @@* Copyright (C) 2007 Stephen Hemminger <[email protected]> */ +#include <linux/kernel.h> #include <linux/module.h> #include <linux/skbuff.h> #include <linux/inet_diag.h>
@@ -23,7 +24,6 @@#define ALPHA_MIN ((3*ALPHA_SCALE)/10)/* ~0.3 */ #define ALPHA_MAX (10*ALPHA_SCALE)/* 10.0 */ #define ALPHA_BASE ALPHA_SCALE/* 1.0 */ -#define U32_MAX ((u32)~0U)#define RTT_MAX (U32_MAX / ALPHA_MAX)/* 3.3 secs */ #define BETA_SHIFT 6
_
David Miller
maintainerFrom: [email protected]
Date: Fri, 10 Aug 2007 14:12:10 -0700
Quoted 11 lines
From: Satyam Sharma <[email protected]>
... in
kernel.hand clean up home-grown macros elsewhere in the tree.Leave out the one in
reiserfs_fs.has it is in the userspace-visible part of that header. Still, #undef the (equivalent) kernel version there to avoid seeing "redefined, previous definition was here" gcc warnings.[[email protected]: fix U16_MAX, U32_MAX defns]Signed-off-by Satyam Sharma <[email protected]>Signed-off-by Andrew Morton <[email protected]>
I won't apply this one, for two reasons:
1) The reiserfs definition is better, it is _type_ based. Please use (~(__u16)0) and (~(__u32)0), respectively.
2) The reiserfs definition is going to define an equivalent value, so just adding an #undef and still letting reiserfs override is wrong. Why put a common define in kernel.h if other headers still keep their own crufty copy too?
Quoted 17 lines · On Fri, 10 Aug 2007 15:38:19 -0700 (PDT) David Miller <[email protected]>…
From: [email protected]
Date: Fri, 10 Aug 2007 14:12:10 -0700Quoted 11 lines
From: Satyam Sharma <[email protected]>
... in
kernel.hand clean up home-grown macros elsewhere in the tree.Leave out the one in
reiserfs_fs.has it is in the userspace-visible part of that header. Still, #undef the (equivalent) kernel version there to avoid seeing "redefined, previous definition was here" gcc warnings.[[email protected]: fix U16_MAX, U32_MAX defns]Signed-off-by Satyam Sharma <[email protected]>Signed-off-by Andrew Morton <[email protected]>I won't apply this one, for two reasons:
Quoted 7 lines
1) The reiserfs definition is better, it is _type_ based. Please use (~(__u16)0) and (~(__u32)0), respectively.
2) The reiserfs definition is going to define an equivalent value, so just adding an #undef and still letting reiserfs override is wrong. Why put a common define in
kernel.hif other headers still keep their own crufty copy too?
OK, I made those changes. Will add to the next batch->davem.
I note that reiserfs has open-coded (~(__u64) 0) in there too...
From: Satyam Sharma <[email protected]>
... in kernel.h and clean up home-grown macros elsewhere in the tree.
---
drivers/net/netconsole.c | 7 +++---- include/linux/kernel.h | 3 +++ include/linux/reiserfs_fs.h | 2 -- net/ipv4/tcp_illinois.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/netconsole.c renamed from drivers/net/netconsole.c~introduce-u16_max-and-u32_max +3 -4
@@ -34,6 +34,7 @@* ****************************************************************/ +#include <linux/kernel.h> #include <linux/mm.h> #include <linux/init.h> #include <linux/module.h>
@@ -389,7 +390,6 @@ static ssize_t store_local_port(struct n size_t count) {long local_port; -#define __U16_MAX ((__u16) ~0U)if (nt->enabled) { printk(KERN_ERR "netconsole: target (%s) is enabled, "
@@ -398,7 +398,7 @@ static ssize_t store_local_port(struct nreturn -EINVAL ; } - local_port =strtol10_check_range (buf,0 , __U16_MAX); + local_port =strtol10_check_range (buf,0 ,U16_MAX );if (local_port <0 )return local_port;
@@ -412,7 +412,6 @@ static ssize_t store_remote_port(struct size_t count) {long remote_port; -#define __U16_MAX ((__u16) ~0U)if (nt->enabled) { printk(KERN_ERR "netconsole: target (%s) is enabled, "
@@ -421,7 +420,7 @@ static ssize_t store_remote_port(structreturn -EINVAL ; } - remote_port =strtol10_check_range (buf,0 , __U16_MAX); + remote_port =strtol10_check_range (buf,0 ,U16_MAX );if (remote_port <0 )return remote_port;
include/linux/kernel.h renamed from include/linux/kernel.h~introduce-u16_max-and-u32_max +3 -0
@@ -30,6 +30,9 @@ extern const char linux_proc_banner[];#define LLONG_MIN (-LLONG_MAX - 1)#define ULLONG_MAX (~0ULL) +#define U16_MAX (~(__u16)0) +#define U32_MAX (~(__u32)0) +#define STACK_MAGIC 0xdeadbeef#define ALIGN (x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
include/linux/reiserfs_fs.h renamed from include/linux/reiserfs_fs.h~introduce-u16_max-and-u32_max +0 -2
@@ -1225,8 +1225,6 @@ struct treepath var = {.path_length = IL#define MAX_US_INT 0xffff// reiserfs version 2 has max offset 60 bits. Version 1 - 32 bit offset -#define U32_MAX (~(__u32)0) -static inline loff_t max_reiserfs_offset (struct inode *inode) {if (get_inode_item_key_version (inode) ==KEY_FORMAT_3_5 )
net/ipv4/tcp_illinois.c renamed from net/ipv4/tcp_illinois.c~introduce-u16_max-and-u32_max +1 -1
@@ -12,6 +12,7 @@* Copyright (C) 2007 Stephen Hemminger <[email protected]> */ +#include <linux/kernel.h> #include <linux/module.h> #include <linux/skbuff.h> #include <linux/inet_diag.h>
@@ -23,7 +24,6 @@#define ALPHA_MIN ((3*ALPHA_SCALE)/10)/* ~0.3 */ #define ALPHA_MAX (10*ALPHA_SCALE)/* 10.0 */ #define ALPHA_BASE ALPHA_SCALE/* 1.0 */ -#define U32_MAX ((u32)~0U)#define RTT_MAX (U32_MAX / ALPHA_MAX)/* 3.3 secs */ #define BETA_SHIFT 6
_
Hi David,
Quoted 11 lines · David Miller
From: [email protected]
Date: Fri, 10 Aug 2007 14:12:10 -0700Quoted 8 lines
From: Satyam Sharma <[email protected]>
... in
kernel.hand clean up home-grown macros elsewhere in the tree.Leave out the one in
reiserfs_fs.has it is in the userspace-visible part of that header. Still, #undef the (equivalent) kernel version there to avoid seeing "redefined, previous definition was here" gcc warnings.
Quoted 8 lines
Quoted 3 lines
[[email protected]: fix U16_MAX, U32_MAX defns]Signed-off-by Satyam Sharma <[email protected]>Signed-off-by Andrew Morton <[email protected]>I won't apply this one, for two reasons:
1) The reiserfs definition is better, it is _type_ based. Please use (~(__u16)0) and (~(__u32)0), respectively.
Hmm, in that case ((__u16)0xffff) and ((__u32)0xffffffff) are probably better and clearer -- as that's what u16_max and u32_max are, after all.
We do require the (~0) thing for the max int/uint/long types, but that's because those are types where the number-of-bits is not known when writing the macro definition -- but that's not case with u16 and u32, so the 0xff... variants are clearer, IMHO.
Quoted 4 lines
2) The reiserfs definition is going to define an equivalent value, so just adding an #undef and still letting reiserfs override is wrong. Why put a common define in
kernel.hif other headers still keep their own crufty copy too?
Because removing the (re-)definition of U32_MAX from in there in reiserfs_fs.h will break builds of all userspace users of U32_MAX and max_reiserfs_offset(), would it not? I haven't looked at any reiserfs userspace tools source code, so possibly none such (that use max_reiserfs_offset) exist, but I thought it better to be safe. I'll have a look at the reiserfs-utils package, just in case.
Thanks,
Satyam
Quoted 22 lines · Satyam Sharma
Hi David,
On Fri, 10 Aug 2007, David Miller wrote:
[...]Quoted 2 lines
1) The reiserfs definition is better, it is _type_ based. Please use (~(__u16)0) and (~(__u32)0), respectively.
Hmm, in that case ((__u16)0xffff) and ((__u32)0xffffffff) are probably better and clearer -- as that's what
u16_maxandu32_maxare, after all.We do require the (~0) thing for the max int/uint/long types, but that's because those are types where the number-of-bits is not known when writing the macro definition -- but that's not case with u16 and u32, so the
0xff... variants are clearer, IMHO.Quoted 4 lines
2) The reiserfs definition is going to define an equivalent value, so just adding an #undef and still letting reiserfs override is wrong. Why put a common define in
kernel.hif other headers still keep their own crufty copy too?
Quoted 6 lines
Because removing the (re-)definition of
U32_MAXfrom in there inreiserfs_fs.hwill break builds of all userspace users ofU32_MAXandmax_reiserfs_offset(), would it not? I haven't looked at any reiserfs userspace tools source code, so possibly none such (that usemax_reiserfs_offset) exist, but I thought it better to be safe. I'll have a look at the reiserfs-utils package, just in case.
I checked with latest reiserfsprogs available from namesys.com and also reiserfs-utils package available from Fedora, and it appears there are no users of either U32_MAX or max_reiserfs_offset() in any userspace reiserfs tools, so we're safe in removing the U32_MAX from include/linux/reiserfs_fs.h.
Thanks,
Satyam
David Miller
maintainerFrom: Satyam Sharma <[email protected]>
Date: Mon, 13 Aug 2007 20:59:09 +0530 (IST)
Quoted 7 lines · David Miller
Quoted 5 lines
2) The reiserfs definition is going to define an equivalent value, so just adding an #undef and still letting reiserfs override is wrong. Why put a common define in
kernel.hif other headers still keep their own crufty copy too?
Quoted 6 lines
Because removing the (re-)definition of
U32_MAXfrom in there inreiserfs_fs.hwill break builds of all userspace users ofU32_MAXandmax_reiserfs_offset(), would it not? I haven't looked at any reiserfs userspace tools source code, so possibly none such (that usemax_reiserfs_offset) exist, but I thought it better to be safe. I'll have a look at the reiserfs-utils package, just in case.
If this is the case then it would be better to pick different macro names from the one's reiserfs already defines in it's header exported userland interfaces.
Or, alternatively, make sure reiserfs's headers get the appropriate headers and defines even when used in userspace.