public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd•com>
To: Joe Perches <joe@perches•com>
Cc: <netdev@vger•kernel.org>, <davem@davemloft•net>
Subject: Re: [PATCH net-next 6/6] amd-xgbe: Resolve checkpatch warning about sscanf usage
Date: Tue, 24 Jun 2014 17:44:18 -0500	[thread overview]
Message-ID: <53A9FF42.2090502@amd.com> (raw)
In-Reply-To: <1403647225.29061.64.camel@joe-AO725>

On 06/24/2014 05:00 PM, Joe Perches wrote:
> On Tue, 2014-06-24 at 16:19 -0500, Tom Lendacky wrote:
>> Checkpatch issued a warning preferring to use kstrto<type> when
>> using a single variable sscanf.  Change the sscanf invocation to
>> a kstrtouint call.
> []
>> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c b/drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c
> []
>> @@ -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?

Using 0 allows for greater flexibility in the input format.

>
>> +	if (ret)
>> +		return ret;
>
> 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.

Tom
>

  reply	other threads:[~2014-06-24 22:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-24 21:19 [PATCH net-next 0/6] amd-xgbe: AMD 10Gb Ethernet driver updates Tom Lendacky
2014-06-24 21:19 ` [PATCH net-next 1/6] amd-xgbe: Make defines in xgbe.h unique Tom Lendacky
2014-06-24 21:19 ` [PATCH net-next 2/6] amd-xgbe: VLAN Tx tag insertion fix Tom Lendacky
2014-06-24 21:19 ` [PATCH net-next 3/6] amd-xgbe: VLAN Rx tag stripping fix Tom Lendacky
2014-06-24 21:19 ` [PATCH net-next 4/6] amd-xgbe: Add support for VLAN filtering Tom Lendacky
2014-06-24 21:19 ` [PATCH net-next 5/6] amd-xgbe: Change destination address filtering support Tom Lendacky
2014-06-24 21:19 ` [PATCH net-next 6/6] amd-xgbe: Resolve checkpatch warning about sscanf usage Tom Lendacky
2014-06-24 22:00   ` Joe Perches
2014-06-24 22:44     ` Tom Lendacky [this message]
2014-06-24 22:53       ` Joe Perches
2014-06-25 13:27         ` Tom Lendacky
2014-06-27  0:12         ` David Miller
2014-06-27 13:35           ` Tom Lendacky
2014-06-27  0:15 ` [PATCH net-next 0/6] amd-xgbe: AMD 10Gb Ethernet driver updates David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53A9FF42.2090502@amd.com \
    --to=thomas.lendacky@amd$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=joe@perches$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox