[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdcNDa++5D6znb8+Dha80tmwPetsGjZ3pafj=D84Fi6TQ@mail.gmail.com>
Date: Wed, 31 May 2017 20:58:51 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Alexandre Courbot <gnurou@...il.com>,
Bamvor Jian Zhang <bamvor.zhangjian@...aro.org>,
"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/7] gpio: mockup: improve the debugfs input sanitization
On Wed, May 31, 2017 at 1:52 PM, Bartosz Golaszewski <brgl@...ev.pl> wrote:
> 2017-05-30 20:52 GMT+02:00 Andy Shevchenko <andy.shevchenko@...il.com>:
>> On Tue, May 30, 2017 at 11:58 AM, Bartosz Golaszewski <brgl@...ev.pl> wrote:
>>> + if (val != 0 && val != 1)
>>
>> Wouldn't be easier to have
>>
>> u8 rv;
>>
>> ret = kstrtu8_from_user();
>> if (ret >= 2)
>> return ...;
>>
>> ?
>
> kstrtu8_from_user() doesn't return the converted value, so you won't
> skip an if anyway
Oh, yes.
> and by using the int variant, we're avoiding a cast.
> I'd prefer it this way frankly.
Fair enough. (Though I would go with (val < 0 && val > 1) condition,
of course it's matter of taste)
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists