diff mbox series

scsi: snic: Convert snprintf to scnprintf

Message ID fe09ebd8774d05dc4038e640d7ddb2e4@208suo.com (mailing list archive)
State Rejected
Headers show
Series scsi: snic: Convert snprintf to scnprintf | expand

Commit Message

hanyu001@208suo.com July 12, 2023, 10:16 a.m. UTC
Coccinelle reports a warning:

drivers/scsi/snic/snic_attrs.c:35: WARNING: use scnprintf or sprintf
drivers/scsi/snic/snic_attrs.c:48: WARNING: use scnprintf or sprintf
drivers/scsi/snic/snic_attrs.c:26: WARNING: use scnprintf or sprintf:

Signed-off-by: ztt <1549089851@qq.com>
---
  drivers/scsi/snic/snic_attrs.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

Comments

David Laight July 14, 2023, 2:56 p.m. UTC | #1
From: hanyu001@208suo.com
> Sent: 12 July 2023 11:16
> 
> Coccinelle reports a warning:
> 
> drivers/scsi/snic/snic_attrs.c:35: WARNING: use scnprintf or sprintf
> drivers/scsi/snic/snic_attrs.c:48: WARNING: use scnprintf or sprintf
> drivers/scsi/snic/snic_attrs.c:26: WARNING: use scnprintf or sprintf:

The function you are looking for is (probably) sysfs_emit().

The PAGE_SIZE constant ought to be a good hint that neither
sprintf, snprintf or scnprintf is actually right.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
diff mbox series

Patch

diff --git a/drivers/scsi/snic/snic_attrs.c 
b/drivers/scsi/snic/snic_attrs.c
index 3ddbdbc3ded1..255cff16c2bd 100644
--- a/drivers/scsi/snic/snic_attrs.c
+++ b/drivers/scsi/snic/snic_attrs.c
@@ -13,7 +13,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 scnprintf(buf, PAGE_SIZE, "%s\n", snic->name);
  }

  static ssize_t
@@ -23,7 +23,7 @@  snic_show_state(struct device *dev,
  {
      struct snic *snic = shost_priv(class_to_shost(dev));

-    return snprintf(buf, PAGE_SIZE, "%s\n",
+    return scnprintf(buf, PAGE_SIZE, "%s\n",
              snic_state_str[snic_get_state(snic)]);
  }

@@ -32,7 +32,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 scnprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION);
  }

  static ssize_t
@@ -45,7 +45,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 scnprintf(buf, PAGE_SIZE, "%s\n",
              (snic->link_status) ? "Link Up" : "Link Down");
  }