Skip to contentSkip to conversation

XFS: Use a signed return type for suffix_kstrtoint()

PATCH In review SF Markus Elfring 3 participants 3 messages Dec 20, 2015 – Dec 21, 2015

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

PATCH 1/1 XFS: Use a signed return type for suffix_kstrtoint()

From: Markus Elfring <[email protected]>
Date: Sun, 20 Dec 2015 07:56:36 +0100

The return type "unsigned long" was used by the suffix_kstrtoint() function even though it will eventually return a negative error code. Improve this implementation detail by using the type "int" instead.

This issue was detected by using the Coccinelle software.

---
 fs/xfs/xfs_super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_super.c +1 -1
index 436b6ef..59c9b7b 100644
@@ -137,7 +137,7 @@ static const match_table_t tokens = {
 };
 
 
-STATIC unsigned long
+STATIC int
 suffix_kstrtoint(char *s, unsigned int base, int *res)
 {
 	int	last, shift_left_factor = 0, _res;
Signature · 1 line
2.6.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 20 Dec 2015 07:56:36 +0100

The return type "unsigned long" was used by the suffix_kstrtoint() function even though it will eventually return a negative error code.

Improve this implementation detail by using the type "int" instead.

This issue was detected by using the Coccinelle software.

yep, looks like an oversight left over from a17164e5

Harmless, because callers only check for non-zero value, but still worth fixing.

Thanks,
-Eric

Quoted 10 lines
---
 fs/xfs/xfs_super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_super.c +0 -0
index 436b6ef..59c9b7b 100644

fs/xfs/xfs_super.c static const match_table_t tokens = { · line 143

Quoted 8 lines
fs/xfs/xfs_super.c +1 -1
@@ -137,7 +137,7 @@ static const match_table_t tokens = {
 };
 
 
-STATIC unsigned long
+STATIC int
 suffix_kstrtoint(char *s, unsigned int base, int *res)
 {
 	int	last, shift_left_factor = 0, _res;

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw
Quoted 9 lines · Eric Sandeen
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 20 Dec 2015 07:56:36 +0100

The return type "unsigned long" was used by the suffix_kstrtoint() function even though it will eventually return a negative error code.

Improve this implementation detail by using the type "int" instead.

Quoted 8 lines
Quoted 3 lines

This issue was detected by using the Coccinelle software.

yep, looks like an oversight left over from a17164e5

Harmless, because callers only check for non-zero value, but still worth fixing.

Perhaps addressing the actual bug in that code would be a more appropriate use of our time. i.e. the undetected integer overflow on left shift....

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs