Skip to contentSkip to conversation

net/ipv4/inetpeer.c stack warnings

DISCUSSION Gabriel C 3 participants 5 messages Jul 19, 2007 – Jul 21, 2007

Subsystems (3)
lore
Share & tools
lore

Gabriel C

author
#0 lore raw

Hello ,

I noticed on current git this warning in net/ipv4/inetpeer.c

...

CC net/ipv4/inetpeer.o
net/ipv4/inetpeer.c: In function 'unlink_from_pool':
net/ipv4/inetpeer.c:297: warning: the address of 'stack' will always evaluate as 'true'
net/ipv4/inetpeer.c:297: warning: the address of 'stack' will always evaluate as 'true'
net/ipv4/inetpeer.c: In function 'inet_getpeer':
net/ipv4/inetpeer.c:409: warning: the address of 'stack' will always evaluate as 'true'
net/ipv4/inetpeer.c:409: warning: the address of 'stack' will always evaluate as 'true'

...

Regards,

Gabriel C

#1 lore raw
Quoted 3 lines · Gabriel C

Hello ,

I noticed on current git this warning in net/ipv4/inetpeer.c

Yeah, I have no idea why the gcc people thought that this was something worth warning about. Especially since explicitly checking for != NULL silences the warning again.

[IPV4]: Fix inetpeer gcc-4.2 warnings

CC net/ipv4/inetpeer.o
net/ipv4/inetpeer.c: In function 'unlink_from_pool':
net/ipv4/inetpeer.c:297: warning: the address of 'stack' will always evaluate as 'true' net/ipv4/inetpeer.c:297: warning: the address of 'stack' will always evaluate as 'true' net/ipv4/inetpeer.c: In function 'inet_getpeer':
net/ipv4/inetpeer.c:409: warning: the address of 'stack' will always evaluate as 'true' net/ipv4/inetpeer.c:409: warning: the address of 'stack' will always evaluate as 'true'

"Fix" by checking for != NULL.

net/ipv4/inetpeer.c +2 -2
index 2f44e61..f725f9f 100644
@@ -158,7 +158,7 @@ static void unlink_from_unused(struct inet_peer *p)
 #define lookup(_daddr,_stack) 					\
 ({								\
 	struct inet_peer *u, **v;				\
-	if (_stack) {						\
+	if (_stack != NULL) {					\
 		stackptr = _stack;				\
 		*stackptr++ = &peer_root;			\
 	}							\
@@ -169,7 +169,7 @@ static void unlink_from_unused(struct inet_peer *p)
 			v = &u->avl_left;			\
 		else						\
 			v = &u->avl_right;			\
-		if (_stack)					\
+		if (_stack != NULL)				\
 			*stackptr++ = v;			\
 		u = *v;						\
 	}							\
author
#2 lore raw
Quoted 13 lines · Patrick McHardy
Quoted 4 lines · Gabriel C

Hello ,

I noticed on current git this warning in net/ipv4/inetpeer.c

Yeah, I have no idea why the gcc people thought that this was something worth warning about. Especially since explicitly checking for != NULL silences the warning again.

Thx , the patch fixes that for me.

Gabriel

maintainer
#3 lore raw
In reply to Patrick McHardy

From: Patrick McHardy <[email protected]>
Date: Thu, 19 Jul 2007 14:48:59 +0200

Quoted 8 lines
Quoted 3 lines · Gabriel C

Hello ,

I noticed on current git this warning in net/ipv4/inetpeer.c

Yeah, I have no idea why the gcc people thought that this was something worth warning about. Especially since explicitly checking for != NULL silences the warning again.

Sigh, applied :-)

maintainer
#4 lore raw
In reply to Gabriel C

From: Gabriel C <[email protected]>
Date: Thu, 19 Jul 2007 14:29:53 +0200

Quoted 6 lines

Hello ,

I noticed on current git this warning in net/ipv4/inetpeer.c

...

Quoted 11 lines

CC net/ipv4/inetpeer.o
net/ipv4/inetpeer.c: In function 'unlink_from_pool':
net/ipv4/inetpeer.c:297: warning: the address of 'stack' will always evaluate as 'true'
net/ipv4/inetpeer.c:297: warning: the address of 'stack' will always evaluate as 'true'
net/ipv4/inetpeer.c: In function 'inet_getpeer':
net/ipv4/inetpeer.c:409: warning: the address of 'stack' will always evaluate as 'true'
net/ipv4/inetpeer.c:409: warning: the address of 'stack' will always evaluate as 'true'

The compiler should not warn about that at all, the lookup() macro is called with "stack" set to NULL.