public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: sunran001@208suo.com
To: jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: hare@kernel.org, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] csi: myrs: Convert snprintf to scnprintf
Date: Fri, 07 Jul 2023 15:36:34 +0800	[thread overview]
Message-ID: <20fbbc099e132bb4d3c367da18051c7c@208suo.com> (raw)
In-Reply-To: <20230707073016.11786-1-xujianghui@cdjrlc.com>

Coccinelle reports: WARNING: use scnprintf or sprintf

Adding to that, there has also been some slow migration from snprintf to
scnprintf. This article explains the rationale for this change:
https: //lwn.net/Articles/69419/

Signed-off-by: RAN SUN <sunran001@208suo.com>
---
  drivers/scsi/myrs.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index a1eec65a9713..852aceb81f28 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -1408,7 +1408,8 @@ 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);

       reply	other threads:[~2023-07-07  7:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230707073016.11786-1-xujianghui@cdjrlc.com>
2023-07-07  7:36 ` sunran001 [this message]
2023-07-12  7:58   ` [PATCH] csi: myrs: Convert snprintf to scnprintf David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20fbbc099e132bb4d3c367da18051c7c@208suo.com \
    --to=sunran001@208suo.com \
    --cc=hare@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox