lkml.org 
[lkml]   [2010]   [Dec]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 26/45] kstrtox: convert drivers/isdn/
On Mon, Dec 06, 2010 at 01:10:45AM +0100, Tilman Schmidt wrote:
> I like the patch, but why not go all the way?
>
> Am 05.12.2010 18:49 schrieb Alexey Dobriyan:
> > @@ -566,10 +566,10 @@ void gigaset_handle_modem_response(struct cardstate *cs)
> > case RT_ZCAU:
> > event->parameter = -1;
> > if (curarg + 1 < params) {
> > - unsigned long type, value;
> > + u8 type, value;
> >
> > - i = strict_strtoul(argv[curarg++], 16, &type);
> > - j = strict_strtoul(argv[curarg++], 16, &value);
> > + i = kstrtou8(argv[curarg++], 16, &type);
> > + j = kstrtou8(argv[curarg++], 16, &value);
> >
> > if (i == 0 && type < 256 &&
> > j == 0 && value < 256)
>
> Once type and value are u8, the checks for < 256 are unnecessary.

OK.

> > @@ -583,7 +583,7 @@ void gigaset_handle_modem_response(struct cardstate *cs)
> > unsigned long res;
> > int rc;
> >
> > - rc = strict_strtoul(argv[curarg++], 10, &res);
> > + rc = kstrtoul(argv[curarg++], 10, &res);
> > if (rc == 0)
> > event->parameter = res;
> > }
>
> The new kstrtoul() promises not to touch the result field in the event
> of a conversion error, so &event->parameter can be passed directly to
> it, getting rid of the variables rc and res and the if statement.

What should be done in case of error?
Compiler will warn if kstrto*() result is unused:

kstrtoul(argv[curarg++], 10, &event->parameter);


\
 
 \ /
  Last update: 2010-12-06 21:13    [W:0.072 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site