From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Baolin Wang <baolin.wang@linaro.org>,
pavel@ucw.cz, rteysseyre@gmail.com, david@lechnology.com,
broonie@kernel.org, linux-leds@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] leds: core: Introduce LED pattern trigger
Date: Thu, 2 Aug 2018 14:53:40 -0700 [thread overview]
Message-ID: <20180802215340.GP30024@minitux> (raw)
In-Reply-To: <34c87589-ccaf-e541-7acb-efcf3bd306f6@gmail.com>
On Thu 02 Aug 14:21 PDT 2018, Jacek Anaszewski wrote:
> On 08/01/2018 11:01 AM, Baolin Wang wrote:
[..]
> > diff --git a/drivers/leds/trigger/ledtrig-pattern.c b/drivers/leds/trigger/ledtrig-pattern.c
[..]
> > +static ssize_t pattern_trig_store_pattern(struct device *dev,
> > + struct device_attribute *attr,
> > + const char *buf, size_t count)
> > +{
> > + struct led_classdev *led_cdev = dev_get_drvdata(dev);
> > + struct pattern_trig_data *data = led_cdev->trigger_data;
> > + int cr, ccount, offset = 0, err = 0;
> > +
> > + if (!data->hardware_pattern)
> > + del_timer_sync(&data->timer);
> > +
> > + mutex_lock(&data->lock);
> > +
> > + data->npatterns = 0;
> > + while (offset < count - 1 && data->npatterns < MAX_PATTERNS) {
> > + cr = 0;
> > + ccount = sscanf(buf + offset, "%d %d " PATTERN_SEPARATOR "%n",
> > + &data->patterns[data->npatterns].brightness,
> > + &data->patterns[data->npatterns].delta_t, &cr);
>
> In case user makes a typo while constructing list of pattern tuples,
> e.g. he forgets a comma, the pattern gets silently truncated.
>
> User is able to detect the truncation by reading pattern file,
> but it is not an immediate feedback anyway.
>
I agree, a failure to parse the entire pattern should result in an error
returned, rather than just silently truncating the pattern.
> I propose that pattern format should require number of tuples in the
> first position which would allow to get rid of this ambiguity, since
> we could verify if the number of parsed tuples is as intended.
>
I would prefer to see that we check that we have consumed the entire
input (accepting optional \n end), rather than having to prepend a count
to the string...
Regards,
Bjorn
next prev parent reply other threads:[~2018-08-02 21:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-01 9:01 [PATCH v2 1/2] leds: core: Introduce LED pattern trigger Baolin Wang
2018-08-01 9:01 ` [PATCH v2 2/2] leds: sc27xx: Add pattern_set/clear interfaces for LED controller Baolin Wang
2018-08-02 21:21 ` [PATCH v2 1/2] leds: core: Introduce LED pattern trigger Jacek Anaszewski
2018-08-02 21:53 ` Bjorn Andersson [this message]
2018-08-03 8:05 ` Baolin Wang
2018-08-03 11:59 ` Jacek Anaszewski
2018-08-04 16:53 ` Baolin Wang
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=20180802215340.GP30024@minitux \
--to=bjorn.andersson@linaro.org \
--cc=baolin.wang@linaro.org \
--cc=broonie@kernel.org \
--cc=david@lechnology.com \
--cc=jacek.anaszewski@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rteysseyre@gmail.com \
/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