Skip to contentSkip to conversation

decnet: Fix complier warning

PATCH Steven Whitehouse 3 participants 4 messages Oct 15, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This patch fixes a warning seen during compiling dn_dev.c. The warning is harmless since we know that the structure length in question is less than 2^32 bytes, but this fixes it anyway.

Cc Christine Caulfield <[email protected]>
net/decnet/dn_dev.c +1 -1
index 2f0ac3c..d9bc69c 100644
@@ -152,7 +152,7 @@ static struct dn_dev_parms dn_dev_list[] =  {
 
 #define DN_DEV_LIST_SIZE ARRAY_SIZE(dn_dev_list)
 
-#define DN_DEV_PARMS_OFFSET(x) ((int) ((char *) &((struct dn_dev_parms *)0)->x))
+#define DN_DEV_PARMS_OFFSET(x) ((long) ((char *) &((struct dn_dev_parms *)0)->x))
 
 #ifdef CONFIG_SYSCTL
 
#1 lore raw
Quoted 12 lines · Steven Whitehouse

This patch fixes a warning seen during compiling dn_dev.c. The warning is harmless since we know that the structure length in question is less than 2^32 bytes, but this fixes it anyway.

Cc Christine Caulfield <[email protected]>
net/decnet/dn_dev.c +0 -0
index 2f0ac3c..d9bc69c 100644

net/decnet/dn_dev.c static struct dn_dev_parms dn_dev_list[] = { · line 158

Quoted 8 lines
net/decnet/dn_dev.c +1 -1
@@ -152,7 +152,7 @@ static struct dn_dev_parms dn_dev_list[] =  {
 
 #define DN_DEV_LIST_SIZE ARRAY_SIZE(dn_dev_list)
 
-#define DN_DEV_PARMS_OFFSET(x) ((int) ((char *) &((struct dn_dev_parms *)0)->x))
+#define DN_DEV_PARMS_OFFSET(x) ((long) ((char *) &((struct dn_dev_parms *)0)->x))
 
 #ifdef CONFIG_SYSCTL
 

Or you could make this use offsetof(). Daring, I know, it's only been a standard macro for nearly 20 years.

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#2 lore raw

Hi,

Quoted 19 lines · Ben Hutchings
Quoted 18 lines · Steven Whitehouse

This patch fixes a warning seen during compiling dn_dev.c. The warning is harmless since we know that the structure length in question is less than 2^32 bytes, but this fixes it anyway.

Cc Christine Caulfield <[email protected]>
net/decnet/dn_dev.c +1 -1
index 2f0ac3c..d9bc69c 100644
@@ -152,7 +152,7 @@ static struct dn_dev_parms dn_dev_list[] =  {
 
 #define DN_DEV_LIST_SIZE ARRAY_SIZE(dn_dev_list)
 
-#define DN_DEV_PARMS_OFFSET(x) ((int) ((char *) &((struct dn_dev_parms *)0)->x))
+#define DN_DEV_PARMS_OFFSET(x) ((long) ((char *) &((struct dn_dev_parms *)0)->x))
 
Quoted 8 lines

net/decnet/dn_dev.c static struct dn_dev_parms dn_dev_list[] = { · line 158

Quoted 2 lines
net/decnet/dn_dev.c +0 -0
 #ifdef CONFIG_SYSCTL
 

Or you could make this use offsetof(). Daring, I know, it's only been a standard macro for nearly 20 years.

Ben.

Yes, thats true. The whole set of code is rather suspect to say the least and I was going for the minimal fix. Its a long time since I last looked at this code so I don't remember exactly why it was done in that way,

Steve.

maintainer
#3 lore raw

From: Steven Whitehouse <[email protected]>
Date: Wed, 15 Oct 2008 13:40:35 +0100

Quoted 8 lines · Ben Hutchings
Quoted 2 lines

Or you could make this use offsetof(). Daring, I know, it's only been a standard macro for nearly 20 years.

Yes, thats true. The whole set of code is rather suspect to say the least and I was going for the minimal fix. Its a long time since I last looked at this code so I don't remember exactly why it was done in that way,

I'm going to check in something like the following:

net/decnet/dn_dev.c +1 -1
index 2f0ac3c..ba35258 100644
@@ -152,7 +152,7 @@ static struct dn_dev_parms dn_dev_list[] =  {
 
 #define DN_DEV_LIST_SIZE ARRAY_SIZE(dn_dev_list)
 
-#define DN_DEV_PARMS_OFFSET(x) ((int) ((char *) &((struct dn_dev_parms *)0)->x))
+#define DN_DEV_PARMS_OFFSET(x) offsetof(struct dn_dev_parms, x)
 
 #ifdef CONFIG_SYSCTL