* [PATCH] iio_trigger_find_by_name: Skip trailing newline if available
@ 2010-03-08 9:31 Hennerich, Michael
2010-03-22 20:37 ` Jonathan Cameron
0 siblings, 1 reply; 7+ messages in thread
From: Hennerich, Michael @ 2010-03-08 9:31 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio@vger.kernel.org,
uclinux-dist-devel@blackfin.uclinux.org
Skip trailing newline if available.
From: Michael Hennerich <Michael.Hennerich@analog.com>
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;
+ 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) {
------------------------------------------------------------------
********* Analog Devices GmbH Open Platform Solutions
** *****
** ** Wilhelm-Wagenfeld-Strasse 6
** ***** D-80807 Munich
********* Germany
Registergericht M=FCnchen HRB 40368, Gesch=E4ftsf=FChrer: Thomas Wessel, W=
illiam A. Martin, Margaret K. Seif
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] iio_trigger_find_by_name: Skip trailing newline if available
@ 2010-03-09 9:35 Hennerich, Michael
2010-03-09 12:42 ` Jonathan Cameron
0 siblings, 1 reply; 7+ messages in thread
From: Hennerich, Michael @ 2010-03-09 9:35 UTC (permalink / raw)
To: Jonathan Cameron, gregkh@suse.de
Cc: linux-iio@vger.kernel.org,
uclinux-dist-devel@blackfin.uclinux.org
Skip trailing newline if available.
From: Michael Hennerich <Michael.Hennerich@analog.com>
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;
+ 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) {
------------------------------------------------------------------
********* Analog Devices GmbH Open Platform Solutions
** *****
** ** Wilhelm-Wagenfeld-Strasse 6
** ***** D-80807 Munich
********* Germany
Registergericht M=FCnchen HRB 40368, Gesch=E4ftsf=FChrer: Thomas Wessel, W=
illiam A. Martin, Margaret K. Seif
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iio_trigger_find_by_name: Skip trailing newline if available
2010-03-09 9:35 [PATCH] iio_trigger_find_by_name: Skip trailing newline if available Hennerich, Michael
@ 2010-03-09 12:42 ` Jonathan Cameron
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2010-03-09 12:42 UTC (permalink / raw)
To: Hennerich, Michael
Cc: gregkh@suse.de, linux-iio@vger.kernel.org,
uclinux-dist-devel@blackfin.uclinux.org
Michael,
You probably want to add your Signed-off-by to this.
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
> Skip trailing newline if available.
>=20
> From: Michael Hennerich <Michael.Hennerich@analog.com>
>=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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iio_trigger_find_by_name: Skip trailing newline if available
2010-03-08 9:31 Hennerich, Michael
@ 2010-03-22 20:37 ` Jonathan Cameron
2010-03-23 12:23 ` Hennerich, Michael
0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2010-03-22 20:37 UTC (permalink / raw)
To: Hennerich, Michael
Cc: linux-iio@vger.kernel.org,
uclinux-dist-devel@blackfin.uclinux.org
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] iio_trigger_find_by_name: Skip trailing newline if available
2010-03-22 20:37 ` Jonathan Cameron
@ 2010-03-23 12:23 ` Hennerich, Michael
2010-03-23 13:46 ` Jonathan Cameron
0 siblings, 1 reply; 7+ messages in thread
From: Hennerich, Michael @ 2010-03-23 12:23 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio@vger.kernel.org,
uclinux-dist-devel@blackfin.uclinux.org
Jonathan Cameron wrote on 2010-03-22:
> On 03/08/10 09:31, Hennerich, Michael wrote:
>> Skip trailing newline if available.
>>
>> 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.
Well - in most cases people use #echo so there shouldn't be a problem with =
white space before and after.
However the newline is going to bug in case you don't use #echo -n.
I've seen many sysfs_set functions also stripping the '\n' from the string.
> Perhaps a cleaner approach is to
> use sscanf to pull out the string alone?
sscanf() is certainly a alternative here.
> 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 particularly clean
> way to do that however.
>
> What do you think?
I agree - Don't allow whitespace in the trigger name.
Michael
>
> Jonathan
>>
>> 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;
>> + 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) {
>> ------------------------------------------------------------------
>> ********* Analog Devices GmbH Open Platform Solutions
>> ** *****
>> ** ** Wilhelm-Wagenfeld-Strasse 6
>> ** ***** D-80807 Munich
>> ********* Germany
>> Registergericht M=FCnchen HRB 40368, Gesch=E4ftsf=FChrer: Thomas Wessel=
,
>> William A. Martin, Margaret K. Seif
>>
>>
>>
Greetings,
Michael
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 4036 Geschaeft=
sfuehrer Thomas Wessel, William A. Martin, Margaret Seif
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] iio_trigger_find_by_name: Skip trailing newline if available
2010-03-23 12:23 ` Hennerich, Michael
@ 2010-03-23 13:46 ` Jonathan Cameron
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2010-03-23 13:46 UTC (permalink / raw)
To: Hennerich, Michael
Cc: linux-iio@vger.kernel.org,
uclinux-dist-devel@blackfin.uclinux.org
On 03/23/10 12:23, Hennerich, Michael wrote:
> Jonathan Cameron wrote on 2010-03-22:
>> On 03/08/10 09:31, Hennerich, Michael wrote:
>>> Skip trailing newline if available.
>>>
>>> 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.
>
> Well - in most cases people use #echo so there shouldn't be a problem with white space before and after.
> However the newline is going to bug in case you don't use #echo -n.
> I've seen many sysfs_set functions also stripping the '\n' from the string.
Actually most uses beyond the debugging drivers stage are likely to be via
userspace libraries, but admittedly these aren't going to have excess white
space so it doesn't matter!
>
>> Perhaps a cleaner approach is to
>> use sscanf to pull out the string alone?
>
> sscanf() is certainly a alternative here.
>
>> 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 particularly clean
>> way to do that however.
>>
>> What do you think?
>
> I agree - Don't allow whitespace in the trigger name.
Alright, I don't really care how we do it, though agree dealing with the newline
is useful, so please send this onto Greg KH (if you haven't?)
Jonathan
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] iio_trigger_find_by_name: Skip trailing newline if available
@ 2010-04-26 8:49 michael.hennerich
0 siblings, 0 replies; 7+ messages in thread
From: michael.hennerich @ 2010-04-26 8:49 UTC (permalink / raw)
To: gregkh
Cc: jic23, uclinux-dist-devel, linux-kernel, linux-iio,
Michael Hennerich
Skip trailing newline if available.
Signed-off-by: Michael Hennerich <Michael.Hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
drivers/staging/iio/industrialio-trigger.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c
index 693ebc4..5f76fc1 100644
--- a/drivers/staging/iio/industrialio-trigger.c
+++ b/drivers/staging/iio/industrialio-trigger.c
@@ -155,6 +155,9 @@ struct iio_trigger *iio_trigger_find_by_name(const char *name, size_t len)
struct iio_trigger *trig;
bool found = false;
+ if (len && name[len - 1] == '\n')
+ len--;
+
mutex_lock(&iio_trigger_list_lock);
list_for_each_entry(trig, &iio_trigger_list, list) {
if (strncmp(trig->name, name, len) == 0) {
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-04-26 8:49 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-09 9:35 [PATCH] iio_trigger_find_by_name: Skip trailing newline if available Hennerich, Michael
2010-03-09 12:42 ` Jonathan Cameron
-- strict thread matches above, loose matches on Subject: below --
2010-04-26 8:49 michael.hennerich
2010-03-08 9:31 Hennerich, Michael
2010-03-22 20:37 ` Jonathan Cameron
2010-03-23 12:23 ` Hennerich, Michael
2010-03-23 13:46 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).