Skip to contentSkip to conversation

fix sparse warning in of_device.c

PATCH In review Robert Reif 2 participants 3 messages Mar 28, 2007 – Mar 29, 2007 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix sparse warning in of_device.c

Fix sparse warning:

arch/sparc/kernel/of_device.c:439:46: warning: incorrect type in argument 3 (different signedness)
arch/sparc/kernel/of_device.c:439:46: expected int *lenp
arch/sparc/kernel/of_device.c:439:46: got unsigned int *<noident>

arch/sparc/kernel/of_device.c +1 -1
index 48c24f7..8c81689 100644
@@ -433,7 +433,7 @@ static int __init build_one_resource(str
 				     int na, int ns, int pna)
 {
 	u32 *ranges;
-	unsigned int rlen;
+	int rlen;
 	int rone;
 
 	ranges = of_get_property(parent, "ranges", &rlen);
maintainer
#1 lore raw

From: Robert Reif <[email protected]>
Date: Wed, 28 Mar 2007 19:07:27 -0400

Quoted 8 lines

Fix sparse warning:

arch/sparc/kernel/of_device.c:439:46: warning: incorrect type in argument 3 (different signedness)
arch/sparc/kernel/of_device.c:439:46: expected int *lenp
arch/sparc/kernel/of_device.c:439:46: got unsigned int *<noident>

Robert, each and every one of these sparc sparse warnings applies to 64-bit sparc as well, the code is nearly identical.

I'm been hitting the sparc64 side for each of your patches, but you can help me out a lot by doing this yourself :-)

Thanks!

maintainer
#2 lore raw
In reply to Robert Reif

From: Robert Reif <[email protected]>
Date: Wed, 28 Mar 2007 19:07:27 -0400

Quoted 8 lines

Fix sparse warning:

arch/sparc/kernel/of_device.c:439:46: warning: incorrect type in argument 3 (different signedness)
arch/sparc/kernel/of_device.c:439:46: expected int *lenp
arch/sparc/kernel/of_device.c:439:46: got unsigned int *<noident>

This patch is not correct.

The loop at the end of this function depends upon the signedness of 'rlen' to handle underflow situations.

With your change to make it unsigned, the loop can possibly not terminate because if 'rlen' gets decremented below zero it will become a "very large positive number" instead of a negative one.