Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1282766 > unrolled thread
| Started by | LABBE Corentin <clabbe.montjoie@gmail.com> |
|---|---|
| First post | 2015-12-03 09:10 +0100 |
| Last post | 2015-12-03 17:40 +0100 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v3 0/1] atm: solos-pci: Replace simple_strtol by kstrtoint LABBE Corentin <clabbe.montjoie@gmail.com> - 2015-12-03 09:10 +0100
[PATCH v3 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint LABBE Corentin <clabbe.montjoie@gmail.com> - 2015-12-03 09:10 +0100
Re: [PATCH v3 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint "Charles (Chas) Williams" <3chas3@gmail.com> - 2015-12-03 12:30 +0100
Re: [PATCH v3 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint LABBE Corentin <clabbe.montjoie@gmail.com> - 2015-12-03 14:00 +0100
Re: [PATCH v3 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint "Charles (Chas) Williams" <3chas3@gmail.com> - 2015-12-03 17:40 +0100
| From | LABBE Corentin <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2015-12-03 09:10 +0100 |
| Subject | [PATCH v3 0/1] atm: solos-pci: Replace simple_strtol by kstrtoint |
| Message-ID | <qBx7I-2kH-1@gated-at.bofh.it> |
Hello Change since v2 - Invert a test logic 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | LABBE Corentin <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2015-12-03 09:10 +0100 |
| Subject | [PATCH v3 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint |
| Message-ID | <qBx7I-2kH-9@gated-at.bofh.it> |
| In reply to | #1282766 |
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..2bec4f1 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 (err || ver < 1) {
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Charles (Chas) Williams" <3chas3@gmail.com> |
|---|---|
| Date | 2015-12-03 12:30 +0100 |
| Subject | Re: [PATCH v3 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint |
| Message-ID | <qBAff-4hh-1@gated-at.bofh.it> |
| In reply to | #1282767 |
On Thu, 2015-12-03 at 09:06 +0100, LABBE Corentin wrote:
> @@ -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 (err || ver < 1) {
> dev_warn(&card->dev->dev, "Unexpected status interrupt version %d\n",
> ver);
> - return -EIO;
> + return err;
If ver < 1 then you might return a 0 here. Always returning -EIO is
probably just fine.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | LABBE Corentin <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2015-12-03 14:00 +0100 |
| Subject | Re: [PATCH v3 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint |
| Message-ID | <qBBEl-58q-3@gated-at.bofh.it> |
| In reply to | #1282955 |
On Thu, Dec 03, 2015 at 06:26:31AM -0500, Charles (Chas) Williams wrote:
> On Thu, 2015-12-03 at 09:06 +0100, LABBE Corentin wrote:
> > @@ -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 (err || ver < 1) {
> > dev_warn(&card->dev->dev, "Unexpected status interrupt version %d\n",
> > ver);
> > - return -EIO;
> > + return err;
>
>
> If ver < 1 then you might return a 0 here. Always returning -EIO is
> probably just fine.
>
Hello
I think the best solution is to split the test, since returning error code from kstrtoint was asked by David Miller.
if (err)
return err;
if (ver < 1)
return -EIO;
Thanks
Regards
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Charles (Chas) Williams" <3chas3@gmail.com> |
|---|---|
| Date | 2015-12-03 17:40 +0100 |
| Subject | Re: [PATCH v3 1/1] atm: solos-pci: Replace simple_strtol by kstrtoint |
| Message-ID | <qBF5h-7z8-27@gated-at.bofh.it> |
| In reply to | #1283022 |
On Thu, 2015-12-03 at 13:58 +0100, LABBE Corentin wrote:
> On Thu, Dec 03, 2015 at 06:26:31AM -0500, Charles (Chas) Williams wrote:
> > On Thu, 2015-12-03 at 09:06 +0100, LABBE Corentin wrote:
> > > @@ -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 (err || ver < 1) {
> > > dev_warn(&card->dev->dev, "Unexpected status interrupt version %d\n",
> > > ver);
> > > - return -EIO;
> > > + return err;
> >
> >
> > If ver < 1 then you might return a 0 here. Always returning -EIO is
> > probably just fine.
> >
>
> Hello
>
> I think the best solution is to split the test, since returning error code from kstrtoint was asked by David Miller.
> if (err)
> return err;
> if (ver < 1)
> return -EIO;
> Thanks
> Regards
That's fine. You just shouldn't return 0 if the ver < 1. This isn't
timing critical code.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web