mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -mm] Introduce U16_MAX and U32_MAX
@ 2007-07-31 16:26 Satyam Sharma
  2007-07-31 18:57 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Satyam Sharma @ 2007-07-31 16:26 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel Mailing List


... 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.

Signed-off-by: Satyam Sharma <satyam@infradead.org>

---

[ On top of previously posted netconsole patches. ]

 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(-)

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 69ef1eb..47a8094 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -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 netconsole_target *nt,
 				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 netconsole_target *nt,
 		return -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 netconsole_target *nt,
 				 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(struct netconsole_target *nt,
 		return -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;
 
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4300bb4..e9221de 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -30,6 +30,9 @@ extern const char linux_proc_banner[];
 #define LLONG_MIN	(-LLONG_MAX - 1)
 #define ULLONG_MAX	(~0ULL)
 
+#define U16_MAX		((u16) ~0U)
+#define U32_MAX		((u32) ~0U)
+
 #define STACK_MAGIC	0xdeadbeef
 
 #define ALIGN(x,a)		__ALIGN_MASK(x,(typeof(x))(a)-1)
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 180a9d8..e452c69 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -1225,6 +1225,7 @@ struct treepath var = {.path_length = ILLEGAL_PATH_ELEMENT_OFFSET, .reada = 0,}
 #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)
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index cc5de6f..227abcd 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -12,6 +12,7 @@
  * Copyright (C) 2007 Stephen Hemminger <shemminger@linux-foundation.org>
  */
 
+#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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -mm] Introduce U16_MAX and U32_MAX
  2007-07-31 16:26 [PATCH -mm] Introduce U16_MAX and U32_MAX Satyam Sharma
@ 2007-07-31 18:57 ` Andrew Morton
  2007-07-31 19:11   ` Jan Engelhardt
  2007-07-31 19:24   ` Satyam Sharma
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Morton @ 2007-07-31 18:57 UTC (permalink / raw)
  To: Satyam Sharma; +Cc: Linux Kernel Mailing List

On Tue, 31 Jul 2007 21:56:12 +0530 (IST)
Satyam Sharma <satyam@infradead.org> wrote:

> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -30,6 +30,9 @@ extern const char linux_proc_banner[];
>  #define LLONG_MIN	(-LLONG_MAX - 1)
>  #define ULLONG_MAX	(~0ULL)
>  
> +#define U16_MAX		((u16) ~0U)
> +#define U32_MAX		((u32) ~0U)
> +

hm, I'd have thought that there's a risk of gcc warnings here, forcing
0xffffffff into a u16, but apparently not.

Still, I think it'd be tidier here to tell the truth and use plain
old 0xffff and 0xffffffff?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -mm] Introduce U16_MAX and U32_MAX
  2007-07-31 18:57 ` Andrew Morton
@ 2007-07-31 19:11   ` Jan Engelhardt
  2007-07-31 19:24   ` Satyam Sharma
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2007-07-31 19:11 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Satyam Sharma, Linux Kernel Mailing List


On Jul 31 2007 11:57, Andrew Morton wrote:
>> --- a/include/linux/kernel.h
>> +++ b/include/linux/kernel.h
>> @@ -30,6 +30,9 @@ extern const char linux_proc_banner[];
>>  #define LLONG_MIN	(-LLONG_MAX - 1)
>>  #define ULLONG_MAX	(~0ULL)
>>  
>> +#define U16_MAX		((u16) ~0U)
>> +#define U32_MAX		((u32) ~0U)
>> +
>
>hm, I'd have thought that there's a risk of gcc warnings here, forcing
>0xffffffff into a u16, but apparently not.

No, since it is casted (= explicitly truncated).


	Jan
-- 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -mm] Introduce U16_MAX and U32_MAX
  2007-07-31 18:57 ` Andrew Morton
  2007-07-31 19:11   ` Jan Engelhardt
@ 2007-07-31 19:24   ` Satyam Sharma
  1 sibling, 0 replies; 4+ messages in thread
From: Satyam Sharma @ 2007-07-31 19:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel Mailing List



On Tue, 31 Jul 2007, Andrew Morton wrote:

> On Tue, 31 Jul 2007 21:56:12 +0530 (IST)
> Satyam Sharma <satyam@infradead.org> wrote:
> 
> > --- a/include/linux/kernel.h
> > +++ b/include/linux/kernel.h
> > @@ -30,6 +30,9 @@ extern const char linux_proc_banner[];
> >  #define LLONG_MIN	(-LLONG_MAX - 1)
> >  #define ULLONG_MAX	(~0ULL)
> >  
> > +#define U16_MAX		((u16) ~0U)
> > +#define U32_MAX		((u32) ~0U)
> > +
> 
> hm, I'd have thought that there's a risk of gcc warnings here, forcing
> 0xffffffff into a u16, but apparently not.
> 
> Still, I think it'd be tidier here to tell the truth and use plain
> old 0xffff and 0xffffffff?

Hmm, that does make sense, actually -- in fact that's the only _really_
correct way to define u32_max / u16_max, I'd say. I probably got confused
seeing those bad examples in reiserfs and tcp_illinois ;-)

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-07-31 19:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-31 16:26 [PATCH -mm] Introduce U16_MAX and U32_MAX Satyam Sharma
2007-07-31 18:57 ` Andrew Morton
2007-07-31 19:11   ` Jan Engelhardt
2007-07-31 19:24   ` Satyam Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®