From: Lee Jones <lee@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH v1 2/4] leds: trigger: gpio: Convert to use kstrtox()
Date: Thu, 23 Nov 2023 14:47:35 +0000 [thread overview]
Message-ID: <20231123144735.GB1354538@google.com> (raw)
In-Reply-To: <ZV9dd6khfmWmj6D_@smile.fi.intel.com>
On Thu, 23 Nov 2023, Andy Shevchenko wrote:
> On Thu, Nov 23, 2023 at 11:05:38AM +0000, Lee Jones wrote:
> > On Fri, 03 Nov 2023, Andy Shevchenko wrote:
>
> ...
>
> > > - ret = sscanf(buf, "%u", &desired_brightness);
>
> "%u" (see man sscanf() for the details)
>
> ...
>
> > > + ret = kstrtou8(buf, 10, &desired_brightness);
> >
> > Where does 10 come from?
>
> See above.
Hmmm ...
I see that this is generally accepted. Although is looks like a recipe
for bugs to me. It's a shame we don't have something that can take a
variable, derives its type, then calculates the maximum length if
converted to a string.
Anyway, I'm probably babbling now ...
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2023-11-23 14:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 19:53 [PATCH v1 1/4] leds: trigger: gpio: Replace custom code for gpiod_get_optional() Andy Shevchenko
2023-11-03 19:53 ` [PATCH v1 2/4] leds: trigger: gpio: Convert to use kstrtox() Andy Shevchenko
2023-11-04 22:26 ` Linus Walleij
2023-11-23 11:05 ` Lee Jones
2023-11-23 14:11 ` Andy Shevchenko
2023-11-23 14:47 ` Lee Jones [this message]
2023-11-03 19:53 ` [PATCH v1 3/4] leds: trigger: gpio: Use sysfs_emit() to instead of s*printf() Andy Shevchenko
2023-11-04 22:24 ` Linus Walleij
2023-11-03 19:53 ` [PATCH v1 4/4] leds: trigger: gpio: Convert to DEVICE_ATTR_RW() Andy Shevchenko
2023-11-04 22:26 ` Linus Walleij
2023-11-04 22:26 ` [PATCH v1 1/4] leds: trigger: gpio: Replace custom code for gpiod_get_optional() Linus Walleij
2023-11-23 14:48 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231123144735.GB1354538@google.com \
--to=lee@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox