From: Jonathan Cameron <jic23@kernel.org>
To: Ioana Ciornei <ciorneiioana@gmail.com>, linux-iio@vger.kernel.org
Cc: mranostay@gmail.com
Subject: Re: [PATCH] tools: iio: avoid returning error when channel does not have an offset
Date: Sat, 31 Oct 2015 10:13:17 +0000 [thread overview]
Message-ID: <5634943D.3080806@kernel.org> (raw)
In-Reply-To: <1446210662-10370-1-git-send-email-ciorneiioana@gmail.com>
On 30/10/15 13:11, Ioana Ciornei wrote:
> This patch avoids getting an error and aborting when a channel does not have a
> specific parameter like 'offset' and the file associated with it is not present.
> When none of the files from the device folder does not matches the desired channel's
> param function iioutils_get_param_float should return 0.
>
> This change is safe previous to calling the function the parameters are set to
> their defaults, 0 in case of 'offset'
>
> Signed-off-by: Ioana Ciornei <ciorneiioana@gmail.com>
This is rather fixing it in the wrong place. This function is specifically getting
the parameter. If it is not there, then the function should return that fact.
It's the caller that should know whether the parameter is optional.
For example, build_channel_array explicitly catches the -ENOENT error and allows
for that case.
Perhaps we need to improve the documentation to make it clear that this is
the expected behaviour?
> ---
> not tested
>
> tools/iio/iio_utils.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
> index 5eb6793..cbaf696 100644
> --- a/tools/iio/iio_utils.c
> +++ b/tools/iio/iio_utils.c
> @@ -241,7 +241,7 @@ int iioutils_get_param_float(float *output, const char *param_name,
> goto error_free_builtname_generic;
> }
>
> - ret = -ENOENT;
> + ret = 0;
> while (ent = readdir(dp), ent)
> if ((strcmp(builtname, ent->d_name) == 0) ||
> (strcmp(builtname_generic, ent->d_name) == 0)) {
>
next prev parent reply other threads:[~2015-10-31 10:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-30 13:11 [PATCH] tools: iio: avoid returning error when channel does not have an offset Ioana Ciornei
2015-10-31 10:13 ` Jonathan Cameron [this message]
2015-10-31 21:27 ` Ioana Ciornei
2015-11-01 11:30 ` Ioana Ciornei
2015-11-01 18:27 ` Jonathan Cameron
2015-11-01 19:53 ` Ioana Ciornei
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=5634943D.3080806@kernel.org \
--to=jic23@kernel.org \
--cc=ciorneiioana@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=mranostay@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 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.