[PATCH] fsi: master: replace snprintf in show functions with sysfs_emit

Joe Perches joe at perches.com
Fri Oct 22 15:49:34 AEDT 2021


On Fri, 2021-10-22 at 02:50 +0000, cgel.zte at gmail.com wrote:
> From: Ye Guojin <ye.guojin at zte.com.cn>
> 
> coccicheck complains about the use of snprintf() in sysfs show
> functions:
> WARNING  use scnprintf or sprintf
[]
> diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c
[]
> @@ -1083,8 +1083,7 @@ static ssize_t external_mode_show(struct device *dev,
>  {
>  	struct fsi_master_acf *master = dev_get_drvdata(dev);
>  
> -	return snprintf(buf, PAGE_SIZE - 1, "%u\n",
> -			master->external_mode ? 1 : 0);
> +	return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);

external_mode is already bool so this ?: isn't necessary.

> diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
[]
> @@ -718,8 +718,7 @@ static ssize_t external_mode_show(struct device *dev,
>  {
>  	struct fsi_master_gpio *master = dev_get_drvdata(dev);
>  
> -	return snprintf(buf, PAGE_SIZE - 1, "%u\n",
> -			master->external_mode ? 1 : 0);
> +	return sysfs_emit(buf, "%u\n", master->external_mode ? 1 : 0);

here too



More information about the linux-fsi mailing list