Re: [PATCH] staging: iio: light: Replace snprintf calls with scnprintf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux