From: Greg KH <gregkh@linuxfoundation.org>
To: Harinath Nampally <harinath922@gmail.com>
Cc: lars@metafoo.de, devel@driverdev.osuosl.org,
Michael.Hennerich@analog.com, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, pmeerw@pmeerw.net, knaack.h@gmx.de,
jic23@kernel.org
Subject: Re: [PATCH] staging: iio: light: Replace snprintf calls with scnprintf
Date: Thu, 25 May 2017 08:46:27 +0200 [thread overview]
Message-ID: <20170525064627.GA7597@kroah.com> (raw)
In-Reply-To: <1495668131-5239-1-git-send-email-harinath922@gmail.com>
On Wed, May 24, 2017 at 07:22:11PM -0400, Harinath Nampally wrote:
> This patch fixes the miscoded use of return value of snprintf
> by using the scnprintf function which returns the length of actual
> string created in the buffer.
>
> Signed-off-by: Harinath Nampally <harinath922@gmail.com>
> ---
> drivers/staging/iio/light/tsl2x7x.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index 1467199..6908bc1 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -921,7 +921,7 @@ static ssize_t power_state_show(struct device *dev,
> {
> struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev));
>
> - return snprintf(buf, PAGE_SIZE, "%d\n", chip->tsl2x7x_chip_status);
> + return scnprintf(buf, PAGE_SIZE, "%d\n", chip->tsl2x7x_chip_status);
It should just be sprintf(), no need for testing for PAGE_SIZE for sysfs
attributes, we "know" an integer will not overflow that buffer.
thanks,
greg k-h
next prev parent reply other threads:[~2017-05-25 6:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 23:22 [PATCH] staging: iio: light: Replace snprintf calls with scnprintf Harinath Nampally
2017-05-25 6:46 ` Greg KH [this message]
2017-05-26 1:14 ` harinath Nampally
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=20170525064627.GA7597@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=Michael.Hennerich@analog.com \
--cc=devel@driverdev.osuosl.org \
--cc=harinath922@gmail.com \
--cc=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=pmeerw@pmeerw.net \
/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