* [PATCH] iio: lsiio: fix error code handling error
@ 2015-08-04 14:21 Linus Walleij
2015-08-04 20:07 ` Hartmut Knaack
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2015-08-04 14:21 UTC (permalink / raw)
To: Jonathan Cameron, linux-iio; +Cc: Linus Walleij, Hartmut Knaack
commit acf50b3586f8d8a7530b905e111dda41876d38f4
"tools:iio:lsiio: add error handling"
introduced error handling of errors returned from
read_sysfs_string(), but with a simple if (retval),
missing the fact that these functions return a positive
value if the read was successful.
As a result lsiio regresses and does not show any
devices on my filesystem. Fix this by checking for
only negative error codes.
Cc: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
tools/iio/lsiio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c
index b59ee1733924..b2c028cc7cac 100644
--- a/tools/iio/lsiio.c
+++ b/tools/iio/lsiio.c
@@ -70,7 +70,7 @@ static int dump_one_device(const char *dev_dir_name)
if (retval != 1)
return -EINVAL;
retval = read_sysfs_string("name", dev_dir_name, name);
- if (retval)
+ if (retval < 0)
return retval;
printf("Device %03d: %s\n", dev_idx, name);
@@ -91,7 +91,7 @@ static int dump_one_trigger(const char *dev_dir_name)
if (retval != 1)
return -EINVAL;
retval = read_sysfs_string("name", dev_dir_name, name);
- if (retval)
+ if (retval < 0)
return retval;
printf("Trigger %03d: %s\n", dev_idx, name);
--
2.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] iio: lsiio: fix error code handling error
2015-08-04 14:21 [PATCH] iio: lsiio: fix error code handling error Linus Walleij
@ 2015-08-04 20:07 ` Hartmut Knaack
2015-08-08 15:07 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Hartmut Knaack @ 2015-08-04 20:07 UTC (permalink / raw)
To: Linus Walleij, Jonathan Cameron, linux-iio
Linus Walleij schrieb am 04.08.2015 um 16:21:
> commit acf50b3586f8d8a7530b905e111dda41876d38f4
> "tools:iio:lsiio: add error handling"
> introduced error handling of errors returned from
> read_sysfs_string(), but with a simple if (retval),
> missing the fact that these functions return a positive
> value if the read was successful.
>
> As a result lsiio regresses and does not show any
> devices on my filesystem. Fix this by checking for
> only negative error codes.
>
> Cc: Hartmut Knaack <knaack.h@gmx.de>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
> ---
> tools/iio/lsiio.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c
> index b59ee1733924..b2c028cc7cac 100644
> --- a/tools/iio/lsiio.c
> +++ b/tools/iio/lsiio.c
> @@ -70,7 +70,7 @@ static int dump_one_device(const char *dev_dir_name)
> if (retval != 1)
> return -EINVAL;
> retval = read_sysfs_string("name", dev_dir_name, name);
> - if (retval)
> + if (retval < 0)
> return retval;
>
> printf("Device %03d: %s\n", dev_idx, name);
> @@ -91,7 +91,7 @@ static int dump_one_trigger(const char *dev_dir_name)
> if (retval != 1)
> return -EINVAL;
> retval = read_sysfs_string("name", dev_dir_name, name);
> - if (retval)
> + if (retval < 0)
> return retval;
>
> printf("Trigger %03d: %s\n", dev_idx, name);
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] iio: lsiio: fix error code handling error
2015-08-04 20:07 ` Hartmut Knaack
@ 2015-08-08 15:07 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2015-08-08 15:07 UTC (permalink / raw)
To: Hartmut Knaack, Linus Walleij, linux-iio
On 04/08/15 21:07, Hartmut Knaack wrote:
> Linus Walleij schrieb am 04.08.2015 um 16:21:
>> commit acf50b3586f8d8a7530b905e111dda41876d38f4
>> "tools:iio:lsiio: add error handling"
>> introduced error handling of errors returned from
>> read_sysfs_string(), but with a simple if (retval),
>> missing the fact that these functions return a positive
>> value if the read was successful.
>>
>> As a result lsiio regresses and does not show any
>> devices on my filesystem. Fix this by checking for
>> only negative error codes.
>>
>> Cc: Hartmut Knaack <knaack.h@gmx.de>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Applied to the fixes-togreg branch of iio.git.
Thanks,
Jonathan
>> ---
>> tools/iio/lsiio.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/iio/lsiio.c b/tools/iio/lsiio.c
>> index b59ee1733924..b2c028cc7cac 100644
>> --- a/tools/iio/lsiio.c
>> +++ b/tools/iio/lsiio.c
>> @@ -70,7 +70,7 @@ static int dump_one_device(const char *dev_dir_name)
>> if (retval != 1)
>> return -EINVAL;
>> retval = read_sysfs_string("name", dev_dir_name, name);
>> - if (retval)
>> + if (retval < 0)
>> return retval;
>>
>> printf("Device %03d: %s\n", dev_idx, name);
>> @@ -91,7 +91,7 @@ static int dump_one_trigger(const char *dev_dir_name)
>> if (retval != 1)
>> return -EINVAL;
>> retval = read_sysfs_string("name", dev_dir_name, name);
>> - if (retval)
>> + if (retval < 0)
>> return retval;
>>
>> printf("Trigger %03d: %s\n", dev_idx, name);
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-08 15:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-04 14:21 [PATCH] iio: lsiio: fix error code handling error Linus Walleij
2015-08-04 20:07 ` Hartmut Knaack
2015-08-08 15:07 ` 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).