From: Jonathan Cameron <jic23@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Hartmut Knaack <knaack.h@gmx.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tools: iio: iio_utils: fix digit calculation
Date: Sun, 16 Oct 2022 17:37:41 +0100 [thread overview]
Message-ID: <20221016173732.1c28ab90@jic23-huawei> (raw)
In-Reply-To: <Y0f+tKCz+ZAIoroQ@dc75zzyyyyyyyyyyyyycy-3.rev.dnainternet.fi>
On Thu, 13 Oct 2022 15:04:04 +0300
Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> The iio_utils uses a digit calculation in order to know length of the
> file name containing a buffer number. The digit calculation does not
> work for number 0.
>
> This leads to allocation of one character too small buffer for the
> file-name when file name contains value '0'. (Eg. buffer0).
>
> Fix digit calculation by returning one digit to be present for number
> '0'.
>
> Fixes: 096f9b862e60 ("tools:iio:iio_utils: implement digit calculation")
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
hi Matti
Makes sense.
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
> ---
> tools/iio/iio_utils.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
> index aadee6d34c74..8d35893b2fa8 100644
> --- a/tools/iio/iio_utils.c
> +++ b/tools/iio/iio_utils.c
> @@ -547,6 +547,10 @@ static int calc_digits(int num)
> {
> int count = 0;
>
> + /* It takes a digit to represent zero */
> + if (!num)
> + return 1;
> +
> while (num != 0) {
> num /= 10;
> count++;
>
> base-commit: 4fe89d07dcc2804c8b562f6c7896a45643d34b2f
prev parent reply other threads:[~2022-10-16 16:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 12:04 [PATCH] tools: iio: iio_utils: fix digit calculation Matti Vaittinen
2022-10-16 16:37 ` Jonathan Cameron [this message]
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=20221016173732.1c28ab90@jic23-huawei \
--to=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@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