Re: [PATCH 2/5] serial: core: add sysfs attribute to suppress ready signalling on open
From: Johan Hovold
Date: Tue Dec 01 2020 - 12:43:24 EST
On Tue, Dec 01, 2020 at 03:49:19PM +0200, Andy Shevchenko wrote:
> On Tue, Dec 1, 2020 at 3:21 PM Johan Hovold <johan@xxxxxxxxxx> wrote:
> > On Tue, Dec 01, 2020 at 01:19:30PM +0200, Andy Shevchenko wrote:
> > > On Tue, Dec 1, 2020 at 1:04 PM Johan Hovold <johan@xxxxxxxxxx> wrote:
>
> ...
>
> > > > 0x01 is 1 and is generally treated as boolean true as you know.
> > >
> > > Depends how you interpret this. kstrtobool() uses one character (and
> > > in some cases two) of the input. Everything else is garbage.
> > > Should we interpret garbage?
> >
> > No, ideally we should reject the input.
>
> We can do it by the way in kstrtobool() and see if anybody complains
> (I believe the world is saner than relying on 0x01 for false and 123
> for true.
I bet someone is using "YEAH!" just because they can. ;)
> ...
>
> > > > So why should a sysfs-interface accept it as valid input and treat it as
> > > > false? That's just bad design.
> > >
> > > I can agree with this.
> >
> > Looks like part of the problem are commits like 4cc7ecb7f2a6 ("param:
> > convert some "on"/"off" users to strtobool") which destroyed perfectly
> > well-defined interfaces.
>
> Oh, but the strtobool() in ABI was before that, for instance
> % git grep -n -p -w strtobool v3.14
> shows a few dozens of users and some of them looks like ABI.
Indeed, it apparently goes further back than strtobool(). The series
introducing strtobool() explicitly mentions the lax parsing and for that
reason wanted to keep it distinct from the other kstrto* function by
dropping the k-prefix:
The naming is still distinct enough from kstrtox to avoid any
implication that this function has the same tight parameter
passing that those functions have.
https://lore.kernel.org/lkml/1303213427-12798-1-git-send-email-jic23@xxxxxxxxx/#t
And it was more recently renamed kstrtobool() anyway.
Let's call it a feature then.
Johan