All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] XFS: Use a signed return type for suffix_kstrtoint()
@ 2015-12-20  7:00 ` SF Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2015-12-20  7:00 UTC (permalink / raw)
  To: xfs, Dave Chinner; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/xfs/xfs_super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 436b6ef..59c9b7b 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -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;
-- 
2.6.3


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

* [PATCH] XFS: Use a signed return type for suffix_kstrtoint()
@ 2015-12-20  7:00 ` SF Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2015-12-20  7:00 UTC (permalink / raw)
  To: xfs, Dave Chinner; +Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/xfs/xfs_super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 436b6ef..59c9b7b 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -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;
-- 
2.6.3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* [PATCH] XFS: Use a signed return type for suffix_kstrtoint()
@ 2015-12-20  7:00 ` SF Markus Elfring
  0 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2015-12-20  7:00 UTC (permalink / raw)
  To: xfs, Dave Chinner; +Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/xfs/xfs_super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 436b6ef..59c9b7b 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -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;
-- 
2.6.3


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

* Re: [PATCH] XFS: Use a signed return type for suffix_kstrtoint()
  2015-12-20  7:00 ` SF Markus Elfring
  (?)
  (?)
@ 2015-12-21 18:35 ` Eric Sandeen
  2015-12-21 21:53   ` Dave Chinner
  -1 siblings, 1 reply; 5+ messages in thread
From: Eric Sandeen @ 2015-12-21 18:35 UTC (permalink / raw)
  To: xfs

On 12/20/15 1:00 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

yep, looks like an oversight left over from a17164e5

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

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

Thanks,
-Eric

> ---
>  fs/xfs/xfs_super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 436b6ef..59c9b7b 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -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
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] XFS: Use a signed return type for suffix_kstrtoint()
  2015-12-21 18:35 ` Eric Sandeen
@ 2015-12-21 21:53   ` Dave Chinner
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Chinner @ 2015-12-21 21:53 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

On Mon, Dec 21, 2015 at 12:35:55PM -0600, Eric Sandeen wrote:
> On 12/20/15 1:00 AM, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > 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.
> 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> 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.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2015-12-21 21:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-20  7:00 [PATCH] XFS: Use a signed return type for suffix_kstrtoint() SF Markus Elfring
2015-12-20  7:00 ` SF Markus Elfring
2015-12-20  7:00 ` SF Markus Elfring
2015-12-21 18:35 ` Eric Sandeen
2015-12-21 21:53   ` Dave Chinner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.