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: <b3961ecdf78e7f88a467650638e5935ea413bb8f.camel@perches.com>
Date:   Sun, 07 Nov 2021 08:13:08 -0800
From:   Joe Perches <joe@...ches.com>
To:     cgel.zte@...il.com, kartilak@...co.com
Cc:     sebaddel@...co.com, jejb@...ux.ibm.com, martin.petersen@...cle.com,
        linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jing Yao <yao.jing2@....com.cn>, Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH] scsi: snic: Replace snprintf in show functions with  
 sysfs_emit

On Fri, 2021-11-05 at 08:14 +0000, cgel.zte@...il.com wrote:
> From: Jing Yao <yao.jing2@....com.cn>
> 
> coccicheck complains about the use of snprintf() in sysfs show
> functions:
> WARNING use scnprintf or sprintf
> 
> Use sysfs_emit instead of scnprintf, snprintf or sprintf makes more
> sense.
[]
> diff --git a/drivers/scsi/snic/snic_attrs.c b/drivers/scsi/snic/snic_attrs.c
[]
> @@ -37,7 +37,7 @@ snic_show_state(struct device *dev,
>  {
>  	struct snic *snic = shost_priv(class_to_shost(dev));
>  
> -	return snprintf(buf, PAGE_SIZE, "%s\n",
> +	return sysfs_emit(buf, "%s\n",
>  			snic_state_str[snic_get_state(snic)]);
>  }

when you do these, please consider the ability to rewrap to 80 columns.

	return sysfs_emit(buf, "%s\n", snic_state_str[snic_get_state(snic)]);

> @@ -59,7 +59,7 @@ snic_show_link_state(struct device *dev,
>  	if (snic->config.xpt_type == SNIC_DAS)
>  		snic->link_status = svnic_dev_link_status(snic->vdev);
>  
> -	return snprintf(buf, PAGE_SIZE, "%s\n",
> +	return sysfs_emit(buf, "%s\n",
>  			(snic->link_status) ? "Link Up" : "Link Down");

And maintain parenthesis alignment

	return sysfs_emit(buf, "%s\n",
 			  snic->link_status ? "Link Up" : "Link Down");

or maybe

	return sysfs_emit(buf, "Link %s\n", snic->link_status ? "Up" : "Down");

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ