* [PATCH v2 0/1] atm: solos-pci: Replace simple_strtol by kstrtoint
@ 2015-12-02 12:54 LABBE Corentin
2015-12-02 12:54 ` [PATCH v2 1/1] " LABBE Corentin
0 siblings, 1 reply; 5+ messages in thread
From: LABBE Corentin @ 2015-12-02 12:54 UTC (permalink / raw)
To: 3chas3, linux-atm-general; +Cc: LABBE Corentin, linux-kernel, netdev
Hello
Change since v1
- Always return error code from kstrtox.
LABBE Corentin (1):
atm: solos-pci: Replace simple_strtol by kstrtoint
drivers/atm/solos-pci.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
--
2.4.10
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint
2015-12-02 12:54 [PATCH v2 0/1] atm: solos-pci: Replace simple_strtol by kstrtoint LABBE Corentin
@ 2015-12-02 12:54 ` LABBE Corentin
2015-12-02 14:02 ` Sergei Shtylyov
0 siblings, 1 reply; 5+ messages in thread
From: LABBE Corentin @ 2015-12-02 12:54 UTC (permalink / raw)
To: 3chas3, linux-atm-general; +Cc: LABBE Corentin, linux-kernel, netdev
The simple_strtol function is obsolete.
This patch replace it by kstrtoint.
This will simplify code, since some error case not handled by
simple_strtol are handled by kstrtoint.
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
drivers/atm/solos-pci.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 3d7fb65..f944d75 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -347,8 +347,8 @@ static char *next_string(struct sk_buff *skb)
*/
static int process_status(struct solos_card *card, int port, struct sk_buff *skb)
{
- char *str, *end, *state_str, *snr, *attn;
- int ver, rate_up, rate_down;
+ char *str, *state_str, *snr, *attn;
+ int ver, rate_up, rate_down, err;
if (!card->atmdev[port])
return -ENODEV;
@@ -357,11 +357,11 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb
if (!str)
return -EIO;
- ver = simple_strtol(str, NULL, 10);
- if (ver < 1) {
+ err = kstrtoint(str, 10, &ver);
+ if (ver < 1 || err) {
dev_warn(&card->dev->dev, "Unexpected status interrupt version %d\n",
ver);
- return -EIO;
+ return err;
}
str = next_string(skb);
@@ -373,16 +373,16 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb
return 0;
}
- rate_down = simple_strtol(str, &end, 10);
- if (*end)
- return -EIO;
+ err = kstrtoint(str, 10, &rate_down);
+ if (err)
+ return err;
str = next_string(skb);
if (!str)
return -EIO;
- rate_up = simple_strtol(str, &end, 10);
- if (*end)
- return -EIO;
+ err = kstrtoint(str, 10, &rate_up);
+ if (err)
+ return err;
state_str = next_string(skb);
if (!state_str)
@@ -417,7 +417,7 @@ static int process_command(struct solos_card *card, int port, struct sk_buff *sk
struct solos_param *prm;
unsigned long flags;
int cmdpid;
- int found = 0;
+ int found = 0, err;
if (skb->len < 7)
return 0;
@@ -428,7 +428,9 @@ static int process_command(struct solos_card *card, int port, struct sk_buff *sk
skb->data[6] != '\n')
return 0;
- cmdpid = simple_strtol(&skb->data[1], NULL, 10);
+ err = kstrtoint(&skb->data[1], 10, &cmdpid);
+ if (err)
+ return err;
spin_lock_irqsave(&card->param_queue_lock, flags);
list_for_each_entry(prm, &card->param_queue, list) {
--
2.4.10
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint
2015-12-02 12:54 ` [PATCH v2 1/1] " LABBE Corentin
@ 2015-12-02 14:02 ` Sergei Shtylyov
2015-12-03 7:52 ` LABBE Corentin
0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2015-12-02 14:02 UTC (permalink / raw)
To: LABBE Corentin, 3chas3, linux-atm-general; +Cc: linux-kernel, netdev
Hello.
On 12/2/2015 3:54 PM, LABBE Corentin wrote:
> The simple_strtol function is obsolete.
> This patch replace it by kstrtoint.
> This will simplify code, since some error case not handled by
> simple_strtol are handled by kstrtoint.
>
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
> drivers/atm/solos-pci.c | 28 +++++++++++++++-------------
> 1 file changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
> index 3d7fb65..f944d75 100644
> --- a/drivers/atm/solos-pci.c
> +++ b/drivers/atm/solos-pci.c
> @@ -347,8 +347,8 @@ static char *next_string(struct sk_buff *skb)
> */
> static int process_status(struct solos_card *card, int port, struct sk_buff *skb)
> {
> - char *str, *end, *state_str, *snr, *attn;
> - int ver, rate_up, rate_down;
> + char *str, *state_str, *snr, *attn;
> + int ver, rate_up, rate_down, err;
>
> if (!card->atmdev[port])
> return -ENODEV;
> @@ -357,11 +357,11 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb
> if (!str)
> return -EIO;
>
> - ver = simple_strtol(str, NULL, 10);
> - if (ver < 1) {
> + err = kstrtoint(str, 10, &ver);
> + if (ver < 1 || err) {
Is 'ver' initialized in case of error? If not, you have to check 'err' first.
[...]
MBR, Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint
2015-12-02 14:02 ` Sergei Shtylyov
@ 2015-12-03 7:52 ` LABBE Corentin
2015-12-03 11:41 ` Sergei Shtylyov
0 siblings, 1 reply; 5+ messages in thread
From: LABBE Corentin @ 2015-12-03 7:52 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: 3chas3, linux-atm-general, linux-kernel, netdev
On Wed, Dec 02, 2015 at 05:02:19PM +0300, Sergei Shtylyov wrote:
> Hello.
>
> On 12/2/2015 3:54 PM, LABBE Corentin wrote:
>
> > The simple_strtol function is obsolete.
> > This patch replace it by kstrtoint.
> > This will simplify code, since some error case not handled by
> > simple_strtol are handled by kstrtoint.
> >
> > Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> > ---
> > drivers/atm/solos-pci.c | 28 +++++++++++++++-------------
> > 1 file changed, 15 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
> > index 3d7fb65..f944d75 100644
> > --- a/drivers/atm/solos-pci.c
> > +++ b/drivers/atm/solos-pci.c
> > @@ -347,8 +347,8 @@ static char *next_string(struct sk_buff *skb)
> > */
> > static int process_status(struct solos_card *card, int port, struct sk_buff *skb)
> > {
> > - char *str, *end, *state_str, *snr, *attn;
> > - int ver, rate_up, rate_down;
> > + char *str, *state_str, *snr, *attn;
> > + int ver, rate_up, rate_down, err;
> >
> > if (!card->atmdev[port])
> > return -ENODEV;
> > @@ -357,11 +357,11 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb
> > if (!str)
> > return -EIO;
> >
> > - ver = simple_strtol(str, NULL, 10);
> > - if (ver < 1) {
> > + err = kstrtoint(str, 10, &ver);
> > + if (ver < 1 || err) {
>
> Is 'ver' initialized in case of error? If not, you have to check 'err' first.
Hello
Whatever if ver is initialized, since the conditional is an or, the test will always be true with the err value.
Anyway I will send an updated version.
Regards
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint
2015-12-03 7:52 ` LABBE Corentin
@ 2015-12-03 11:41 ` Sergei Shtylyov
0 siblings, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2015-12-03 11:41 UTC (permalink / raw)
To: LABBE Corentin; +Cc: 3chas3, linux-atm-general, linux-kernel, netdev
Hello.
On 12/3/2015 10:52 AM, LABBE Corentin wrote:
>>> The simple_strtol function is obsolete.
>>> This patch replace it by kstrtoint.
>>> This will simplify code, since some error case not handled by
>>> simple_strtol are handled by kstrtoint.
>>>
>>> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
>>> ---
>>> drivers/atm/solos-pci.c | 28 +++++++++++++++-------------
>>> 1 file changed, 15 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
>>> index 3d7fb65..f944d75 100644
>>> --- a/drivers/atm/solos-pci.c
>>> +++ b/drivers/atm/solos-pci.c
>>> @@ -347,8 +347,8 @@ static char *next_string(struct sk_buff *skb)
>>> */
>>> static int process_status(struct solos_card *card, int port, struct sk_buff *skb)
>>> {
>>> - char *str, *end, *state_str, *snr, *attn;
>>> - int ver, rate_up, rate_down;
>>> + char *str, *state_str, *snr, *attn;
>>> + int ver, rate_up, rate_down, err;
>>>
>>> if (!card->atmdev[port])
>>> return -ENODEV;
>>> @@ -357,11 +357,11 @@ static int process_status(struct solos_card *card, int port, struct sk_buff *skb
>>> if (!str)
>>> return -EIO;
>>>
>>> - ver = simple_strtol(str, NULL, 10);
>>> - if (ver < 1) {
>>> + err = kstrtoint(str, 10, &ver);
>>> + if (ver < 1 || err) {
>>
>> Is 'ver' initialized in case of error? If not, you have to check 'err' first.
>
> Hello
>
> Whatever if ver is initialized,
I meant initialized by kstrtoint().
> since the conditional is an or, the test will always be true with the err value.
I don't understand you. If you test 'ver' first, you risk testing
uninitialized variable.
> Anyway I will send an updated version.
Let's see...
> Regards
MBR, Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-12-03 11:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-02 12:54 [PATCH v2 0/1] atm: solos-pci: Replace simple_strtol by kstrtoint LABBE Corentin
2015-12-02 12:54 ` [PATCH v2 1/1] " LABBE Corentin
2015-12-02 14:02 ` Sergei Shtylyov
2015-12-03 7:52 ` LABBE Corentin
2015-12-03 11:41 ` Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).