lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210203204405.GG106766@roeck-us.net>
Date:   Wed, 3 Feb 2021 12:44:05 -0800
From:   Guenter Roeck <linux@...ck-us.net>
To:     Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Cc:     jdelvare@...e.com, linux-hwmon@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] hwmon: (pmbus) convert sysfs sprintf/snprintf family
 to sysfs_emit

On Tue, Feb 02, 2021 at 04:49:03PM +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warning:
> 
> ./drivers/hwmon/pmbus/inspur-ipsps.c:73:8-16: WARNING: use scnprintf or
> sprintf.
> 
> ./drivers/hwmon/pmbus/inspur-ipsps.c:114:9-17: WARNING: use scnprintf or
> sprintf.
> 
> ./drivers/hwmon/pmbus/inspur-ipsps.c:94:8-16: WARNING: use scnprintf or
> sprintf.
> 
> Reported-by: Abaci Robot<abaci@...ux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>

Please refrain from such changes. I'll accept them only if other changes
are made to the driver at the same time.

Guenter

> ---
> Changes in v2:
>   -Modified code space.
> 
>  drivers/hwmon/pmbus/inspur-ipsps.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/inspur-ipsps.c b/drivers/hwmon/pmbus/inspur-ipsps.c
> index 88c5865..bf593fd 100644
> --- a/drivers/hwmon/pmbus/inspur-ipsps.c
> +++ b/drivers/hwmon/pmbus/inspur-ipsps.c
> @@ -70,7 +70,7 @@ static ssize_t ipsps_string_show(struct device *dev,
>  	p = memscan(data, '#', rc);
>  	*p = '\0';
>  
> -	return snprintf(buf, PAGE_SIZE, "%s\n", data);
> +	return sysfs_emit(buf, "%s\n", data);
>  }
>  
>  static ssize_t ipsps_fw_version_show(struct device *dev,
> @@ -91,9 +91,9 @@ static ssize_t ipsps_fw_version_show(struct device *dev,
>  	if (rc != 6)
>  		return -EPROTO;
>  
> -	return snprintf(buf, PAGE_SIZE, "%u.%02u%u-%u.%02u\n",
> -			data[1], data[2]/* < 100 */, data[3]/*< 10*/,
> -			data[4], data[5]/* < 100 */);
> +	return sysfs_emit(buf, "%u.%02u%u-%u.%02u\n",
> +			  data[1], data[2]/* < 100 */, data[3]/*< 10*/,
> +			  data[4], data[5]/* < 100 */);
>  }
>  
>  static ssize_t ipsps_mode_show(struct device *dev,
> @@ -111,19 +111,19 @@ static ssize_t ipsps_mode_show(struct device *dev,
>  
>  	switch (rc) {
>  	case MODE_ACTIVE:
> -		return snprintf(buf, PAGE_SIZE, "[%s] %s %s\n",
> -				MODE_ACTIVE_STRING,
> -				MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING);
> +		return sysfs_emit(buf, "[%s] %s %s\n",
> +				  MODE_ACTIVE_STRING,
> +				  MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING);
>  	case MODE_STANDBY:
> -		return snprintf(buf, PAGE_SIZE, "%s [%s] %s\n",
> -				MODE_ACTIVE_STRING,
> -				MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING);
> +		return sysfs_emit(buf, "%s [%s] %s\n",
> +				  MODE_ACTIVE_STRING,
> +				  MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING);
>  	case MODE_REDUNDANCY:
> -		return snprintf(buf, PAGE_SIZE, "%s %s [%s]\n",
> -				MODE_ACTIVE_STRING,
> -				MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING);
> +		return sysfs_emit(buf, "%s %s [%s]\n",
> +				  MODE_ACTIVE_STRING,
> +				  MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING);
>  	default:
> -		return snprintf(buf, PAGE_SIZE, "unspecified\n");
> +		return sysfs_emit(buf, "unspecified\n");
>  	}
>  }
>  
> -- 
> 1.8.3.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ