From: Jonathan Cameron <jic23@cam.ac.uk>
To: "Hennerich, Michael" <Michael.Hennerich@analog.com>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"uclinux-dist-devel@blackfin.uclinux.org"
<uclinux-dist-devel@blackfin.uclinux.org>
Subject: Re: [PATCH] iio_trigger_find_by_name: Skip trailing newline if available
Date: Mon, 22 Mar 2010 20:37:33 +0000 [thread overview]
Message-ID: <4BA7D50D.2080202@cam.ac.uk> (raw)
In-Reply-To: <544AC56F16B56944AEC3BD4E3D5917712D6B1D944F@LIMKCMBX1.ad.analog.com>
On 03/08/10 09:31, Hennerich, Michael wrote:
> Skip trailing newline if available.
>=20
> From: Michael Hennerich <Michael.Hennerich@analog.com>
Dear Michael,
Just found this one whilst trying to sort out a clean iio tree.
(sorry I completely failed to reply originally)
Anyhow, I agree with the principal that we should be ignoring the
newline. Actually we should be ignoring whitespace before and after
the string we are actually after. Perhaps a cleaner approach
is to use sscanf to pull out the string alone? I don't think
we need to allow for whitespace in the trigger name (though obviously
it should be documented if we do not). Technically I believe
(via the convenient lwn article last week on the topic) we should
ignore white space but return -EINVAL if there is say one word, some
white space and then another word... Not sure if there is a particular=
ly
clean way to do that however.
What do you think?
Jonathan
>=20
> Index: drivers/staging/iio/industrialio-trigger.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- drivers/staging/iio/industrialio-trigger.c (revision 8368)
> +++ drivers/staging/iio/industrialio-trigger.c (working copy)
> @@ -155,6 +155,9 @@
> struct iio_trigger *trig;
> bool found =3D false;
>=20
> + if (len && name[len - 1] =3D=3D '\n')
> + len--;
> +
> mutex_lock(&iio_trigger_list_lock);
> list_for_each_entry(trig, &iio_trigger_list, list) {
> if (strncmp(trig->name, name, len) =3D=3D 0) {
>=20
> ------------------------------------------------------------------
> ********* Analog Devices GmbH Open Platform Solutions
> ** *****
> ** ** Wilhelm-Wagenfeld-Strasse 6
> ** ***** D-80807 Munich
> ********* Germany
> Registergericht M=FCnchen HRB 40368, Gesch=E4ftsf=FChrer: Thomas Wes=
sel, William A. Martin, Margaret K. Seif
>=20
>=20
>=20
next prev parent reply other threads:[~2010-03-22 20:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-08 9:31 [PATCH] iio_trigger_find_by_name: Skip trailing newline if available Hennerich, Michael
2010-03-22 20:37 ` Jonathan Cameron [this message]
2010-03-23 12:23 ` Hennerich, Michael
2010-03-23 13:46 ` Jonathan Cameron
-- strict thread matches above, loose matches on Subject: below --
2010-03-09 9:35 Hennerich, Michael
2010-03-09 12:42 ` Jonathan Cameron
2010-03-09 13:00 Hennerich, Michael
2010-04-26 8:49 michael.hennerich
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=4BA7D50D.2080202@cam.ac.uk \
--to=jic23@cam.ac.uk \
--cc=Michael.Hennerich@analog.com \
--cc=linux-iio@vger.kernel.org \
--cc=uclinux-dist-devel@blackfin.uclinux.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.