All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netfilter: xt_IDLETIMER: replace snprintf in show functions with sysfs_emit
@ 2021-11-04 11:49 cgel.zte
  2021-11-08 11:18 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: cgel.zte @ 2021-11-04 11:49 UTC (permalink / raw)
  To: pablo
  Cc: kadlec, fw, davem, kuba, netfilter-devel, coreteam, netdev,
	linux-kernel, Jing Yao, Zeal Robot

From: Jing Yao <yao.jing2@zte.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.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>
---
 net/netfilter/xt_IDLETIMER.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c
index 2f7cf5ecebf4..0f8bb0bf558f 100644
--- a/net/netfilter/xt_IDLETIMER.c
+++ b/net/netfilter/xt_IDLETIMER.c
@@ -85,9 +85,9 @@ static ssize_t idletimer_tg_show(struct device *dev,
 	mutex_unlock(&list_mutex);
 
 	if (time_after(expires, jiffies) || ktimespec.tv_sec > 0)
-		return snprintf(buf, PAGE_SIZE, "%ld\n", time_diff);
+		return sysfs_emit(buf, "%ld\n", time_diff);
 
-	return snprintf(buf, PAGE_SIZE, "0\n");
+	return sysfs_emit(buf, "0\n");
 }
 
 static void idletimer_tg_work(struct work_struct *work)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: xt_IDLETIMER: replace snprintf in show functions with sysfs_emit
  2021-11-04 11:49 [PATCH] netfilter: xt_IDLETIMER: replace snprintf in show functions with sysfs_emit cgel.zte
@ 2021-11-08 11:18 ` Pablo Neira Ayuso
  2021-11-10  2:55   ` [PATCH v2] scsi: snic: Replace " cgel.zte
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2021-11-08 11:18 UTC (permalink / raw)
  To: cgel.zte
  Cc: kadlec, fw, davem, kuba, netfilter-devel, coreteam, netdev,
	linux-kernel, Jing Yao, Zeal Robot

On Thu, Nov 04, 2021 at 11:49:11AM +0000, cgel.zte@gmail.com wrote:
> From: Jing Yao <yao.jing2@zte.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.

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] scsi: snic: Replace snprintf in show functions with  sysfs_emit
  2021-11-08 11:18 ` Pablo Neira Ayuso
@ 2021-11-10  2:55   ` cgel.zte
  0 siblings, 0 replies; 3+ messages in thread
From: cgel.zte @ 2021-11-10  2:55 UTC (permalink / raw)
  To: pablo
  Cc: cgel.zte, coreteam, davem, fw, kadlec, kuba, linux-kernel,
	netdev, netfilter-devel, yao.jing2, zealci

From: Jing Yao <yao.jing2@zte.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.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Jing Yao <yao.jing2@zte.com.cn>
---

Changes since v1:
 - Revise to meet the format "80 columns".
 - Revise to maintain parenthesis alignment.

 drivers/scsi/snic/snic_attrs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/snic/snic_attrs.c b/drivers/scsi/snic/snic_attrs.c
index dc03ce1ec909..de1fee9246dc 100644
--- a/drivers/scsi/snic/snic_attrs.c
+++ b/drivers/scsi/snic/snic_attrs.c
@@ -27,7 +27,7 @@ snic_show_sym_name(struct device *dev,
 {
 	struct snic *snic = shost_priv(class_to_shost(dev));
 
-	return snprintf(buf, PAGE_SIZE, "%s\n", snic->name);
+	return sysfs_emit(buf, "%s\n", snic->name);
 }
 
 static ssize_t
@@ -37,8 +37,7 @@ snic_show_state(struct device *dev,
 {
 	struct snic *snic = shost_priv(class_to_shost(dev));
 
-	return snprintf(buf, PAGE_SIZE, "%s\n",
-			snic_state_str[snic_get_state(snic)]);
+	return sysfs_emit(buf, "%s\n", snic_state_str[snic_get_state(snic)]);
 }
 
 static ssize_t
@@ -46,7 +45,7 @@ snic_show_drv_version(struct device *dev,
 		      struct device_attribute *attr,
 		      char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION);
+	return sysfs_emit(buf, "%s\n", SNIC_DRV_VERSION);
 }
 
 static ssize_t
@@ -59,8 +58,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",
-			(snic->link_status) ? "Link Up" : "Link Down");
+	return sysfs_emit(buf, "Link %s\n", snic->link_status ? "Up" : "Down");
 }
 
 static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-10  2:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 11:49 [PATCH] netfilter: xt_IDLETIMER: replace snprintf in show functions with sysfs_emit cgel.zte
2021-11-08 11:18 ` Pablo Neira Ayuso
2021-11-10  2:55   ` [PATCH v2] scsi: snic: Replace " cgel.zte

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.