Thread (14 messages) 14 messages, 3 authors, 2014-06-27

Re: [PATCH net-next 6/6] amd-xgbe: Resolve checkpatch warning about sscanf usage

From: Tom Lendacky <thomas.lendacky@amd.com>
Date: 2014-06-25 13:28:01

On 06/24/2014 05:53 PM, Joe Perches wrote:
On Tue, 2014-06-24 at 17:44 -0500, Tom Lendacky wrote:
quoted
On 06/24/2014 05:00 PM, Joe Perches wrote:
quoted
On Tue, 2014-06-24 at 16:19 -0500, Tom Lendacky wrote:
quoted
Checkpatch issued a warning preferring to use kstrto<type> when
using a single variable sscanf.  Change the sscanf invocation to
a kstrtouint call.
[]
quoted
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
[]
quoted
@@ -165,10 +165,9 @@ static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
   		return len;

   	workarea[len] = '\0';
-	if (sscanf(workarea, "%x", &scan_value) == 1)
-		*value = scan_value;
-	else
-		return -EIO;
+	ret = kstrtouint(workarea, 0, value);
Don't you need to use 16 for the base here?
quoted
Using 0 allows for greater flexibility in the input format.
True, but there could be a change in behavior like reading a
previously hex value like 10 is now a decimal 10 not decimal 16.
quoted
quoted
Are there any issues with any of the various callers
getting a different error return?

-EINVAL/-ERANGE vs -EIO ?
There shouldn't be, but I can always return -EIO to be
consistent with how it was previously.
Up to you Tom.  I just wanted you to think about it.
Understood.  This is a brand new driver that is still being developed
so I have some latitude initially on what and how I make changes. I
understand that later I'll have to maintain behaviors, interfaces, etc.

Thanks,
Tom
cheers, Joe
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help