mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: Convert snprintf to scnprintf
       [not found] <tencent_BEB5DAE7D9027BD58E958AE34A443CB4CB08@qq.com>
@ 2023-07-17  3:19 ` hanyu001
  0 siblings, 0 replies; 2+ messages in thread
From: hanyu001 @ 2023-07-17  3:19 UTC (permalink / raw)
  To: jejb, martin.petersen; +Cc: linux-scsi, linux-kernel

Fix the following coccicheck warnings:

./drivers/scsi/myrb.c:2143:8-16: WARNING: use scnprintf or sprintf
./drivers/scsi/myrb.c:2153:8-16: WARNING: use scnprintf or sprintf
./drivers/scsi/myrb.c:2163:8-16: WARNING: use scnprintf or sprintf
./drivers/scsi/myrb.c:1889:10-18: WARNING: use scnprintf or sprintf
./drivers/scsi/myrb.c:1770:9-17: WARNING: use scnprintf or sprintf
./drivers/scsi/myrb.c:1906:9-17: WARNING: use scnprintf or sprintf

Signed-off-by: ztt <1549089851@qq.com>
---
  drivers/scsi/myrb.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index ca2e932dd9b7..7e3712c6e08f 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -1767,7 +1767,7 @@ static ssize_t raid_state_show(struct device *dev,
      int ret;

      if (!sdev->hostdata)
-        return snprintf(buf, 16, "Unknown\n");
+        return scnprintf(buf, 16, "Unknown\n");

      if (sdev->channel == myrb_logical_channel(sdev->host)) {
          struct myrb_ldev_info *ldev_info = sdev->hostdata;
@@ -1886,7 +1886,7 @@ static ssize_t raid_level_show(struct device *dev,

          name = myrb_raidlevel_name(ldev_info->raid_level);
          if (!name)
-            return snprintf(buf, 32, "Invalid (%02X)\n",
+            return scnprintf(buf, 32, "Invalid (%02X)\n",
                      ldev_info->state);
          return snprintf(buf, 32, "%s\n", name);
      }
@@ -1903,7 +1903,7 @@ static ssize_t rebuild_show(struct device *dev,
      unsigned char status;

      if (sdev->channel < myrb_logical_channel(sdev->host))
-        return snprintf(buf, 32, "physical device - not rebuilding\n");
+        return scnprintf(buf, 32, "physical device - not 
rebuilding\n");

      status = myrb_get_rbld_progress(cb, &rbld_buf);

@@ -2140,7 +2140,7 @@ static ssize_t ctlr_num_show(struct device *dev,
      struct Scsi_Host *shost = class_to_shost(dev);
      struct myrb_hba *cb = shost_priv(shost);

-    return snprintf(buf, 20, "%u\n", cb->ctlr_num);
+    return scnprintf(buf, 20, "%u\n", cb->ctlr_num);
  }
  static DEVICE_ATTR_RO(ctlr_num);

@@ -2150,7 +2150,7 @@ static ssize_t firmware_show(struct device *dev,
      struct Scsi_Host *shost = class_to_shost(dev);
      struct myrb_hba *cb = shost_priv(shost);

-    return snprintf(buf, 16, "%s\n", cb->fw_version);
+    return scnprintf(buf, 16, "%s\n", cb->fw_version);
  }
  static DEVICE_ATTR_RO(firmware);

@@ -2160,7 +2160,7 @@ static ssize_t model_show(struct device *dev,
      struct Scsi_Host *shost = class_to_shost(dev);
      struct myrb_hba *cb = shost_priv(shost);

-    return snprintf(buf, 16, "%s\n", cb->model_name);
+    return scnprintf(buf, 16, "%s\n", cb->model_name);
  }
  static DEVICE_ATTR_RO(model);

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

* [PATCH] scsi: Convert snprintf to scnprintf
       [not found] <tencent_104520BE1ABA5274FC82089096A176EA5C05@qq.com>
@ 2023-07-17  6:44 ` hanyu001
  0 siblings, 0 replies; 2+ messages in thread
From: hanyu001 @ 2023-07-17  6:44 UTC (permalink / raw)
  To: jejb, martin.petersen; +Cc: linux-scsi, linux-kernel

Fix the following coccicheck warnings:

./drivers/scsi/myrs.c:1411:8-16: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:1193:9-17: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:1316:8-16: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:1401:8-16: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:1491:8-16: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:1421:8-16: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:1391:8-16: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:1061:9-17: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:942:9-17: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:1089:9-17: WARNING: use scnprintf or sprintf
./drivers/scsi/myrs.c:1306:8-16: WARNING: use scnprintf or sprintf

Signed-off-by: ztt <1549089851@qq.com>
---
  drivers/scsi/myrs.c | 22 +++++++++++-----------
  1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index a1eec65a9713..ced1d2fbd862 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -939,7 +939,7 @@ static ssize_t raid_state_show(struct device *dev,
      int ret;

      if (!sdev->hostdata)
-        return snprintf(buf, 16, "Unknown\n");
+        return scnprintf(buf, 16, "Unknown\n");

      if (sdev->channel >= cs->ctlr_info->physchan_present) {
          struct myrs_ldev_info *ldev_info = sdev->hostdata;
@@ -1058,7 +1058,7 @@ static ssize_t raid_level_show(struct device *dev,
      const char *name = NULL;

      if (!sdev->hostdata)
-        return snprintf(buf, 16, "Unknown\n");
+        return scnprintf(buf, 16, "Unknown\n");

      if (sdev->channel >= cs->ctlr_info->physchan_present) {
          struct myrs_ldev_info *ldev_info;
@@ -1086,7 +1086,7 @@ static ssize_t rebuild_show(struct device *dev,
      unsigned char status;

      if (sdev->channel < cs->ctlr_info->physchan_present)
-        return snprintf(buf, 32, "physical device - not rebuilding\n");
+        return scnprintf(buf, 32, "physical device - not 
rebuilding\n");

      ldev_info = sdev->hostdata;
      ldev_num = ldev_info->ldev_num;
@@ -1190,7 +1190,7 @@ static ssize_t consistency_check_show(struct 
device *dev,
      unsigned short ldev_num;

      if (sdev->channel < cs->ctlr_info->physchan_present)
-        return snprintf(buf, 32, "physical device - not checking\n");
+        return scnprintf(buf, 32, "physical device - not checking\n");

      ldev_info = sdev->hostdata;
      if (!ldev_info)
@@ -1303,7 +1303,7 @@ static ssize_t serial_show(struct device *dev,

      memcpy(serial, cs->ctlr_info->serial_number, 16);
      serial[16] = '\0';
-    return snprintf(buf, 16, "%s\n", serial);
+    return scnprintf(buf, 16, "%s\n", serial);
  }
  static DEVICE_ATTR_RO(serial);

@@ -1313,7 +1313,7 @@ static ssize_t ctlr_num_show(struct device *dev,
      struct Scsi_Host *shost = class_to_shost(dev);
      struct myrs_hba *cs = shost_priv(shost);

-    return snprintf(buf, 20, "%d\n", cs->host->host_no);
+    return scnprintf(buf, 20, "%d\n", cs->host->host_no);
  }
  static DEVICE_ATTR_RO(ctlr_num);

@@ -1388,7 +1388,7 @@ static ssize_t model_show(struct device *dev,
      struct Scsi_Host *shost = class_to_shost(dev);
      struct myrs_hba *cs = shost_priv(shost);

-    return snprintf(buf, 28, "%s\n", cs->model_name);
+    return scnprintf(buf, 28, "%s\n", cs->model_name);
  }
  static DEVICE_ATTR_RO(model);

@@ -1398,7 +1398,7 @@ static ssize_t ctlr_type_show(struct device *dev,
      struct Scsi_Host *shost = class_to_shost(dev);
      struct myrs_hba *cs = shost_priv(shost);

-    return snprintf(buf, 4, "%d\n", cs->ctlr_info->ctlr_type);
+    return scnprintf(buf, 4, "%d\n", cs->ctlr_info->ctlr_type);
  }
  static DEVICE_ATTR_RO(ctlr_type);

@@ -1408,7 +1408,7 @@ static ssize_t cache_size_show(struct device *dev,
      struct Scsi_Host *shost = class_to_shost(dev);
      struct myrs_hba *cs = shost_priv(shost);

-    return snprintf(buf, 8, "%d MB\n", cs->ctlr_info->cache_size_mb);
+    return scnprintf(buf, 8, "%d MB\n", cs->ctlr_info->cache_size_mb);
  }
  static DEVICE_ATTR_RO(cache_size);

@@ -1418,7 +1418,7 @@ static ssize_t firmware_show(struct device *dev,
      struct Scsi_Host *shost = class_to_shost(dev);
      struct myrs_hba *cs = shost_priv(shost);

-    return snprintf(buf, 16, "%d.%02d-%02d\n",
+    return scnprintf(buf, 16, "%d.%02d-%02d\n",
              cs->ctlr_info->fw_major_version,
              cs->ctlr_info->fw_minor_version,
              cs->ctlr_info->fw_turn_number);
@@ -1488,7 +1488,7 @@ static ssize_t 
disable_enclosure_messages_show(struct device *dev,
      struct Scsi_Host *shost = class_to_shost(dev);
      struct myrs_hba *cs = shost_priv(shost);

-    return snprintf(buf, 3, "%d\n", cs->disable_enc_msg);
+    return scnprintf(buf, 3, "%d\n", cs->disable_enc_msg);
  }

  static ssize_t disable_enclosure_messages_store(struct device *dev,

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

end of thread, other threads:[~2023-07-17  6:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <tencent_BEB5DAE7D9027BD58E958AE34A443CB4CB08@qq.com>
2023-07-17  3:19 ` [PATCH] scsi: Convert snprintf to scnprintf hanyu001
     [not found] <tencent_104520BE1ABA5274FC82089096A176EA5C05@qq.com>
2023-07-17  6:44 ` hanyu001

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome