mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Deepak R Varma <drv@mailo.com>
To: Hannes Reinecke <hare@kernel.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Saurabh Singh Sengar <ssengar@microsoft.com>,
	Praveen Kumar <kumarpraveen@linux.microsoft.com>,
	drv@mailo.com
Subject: [PATCH] scsi: myrs: Use sysfs_emit in show function callsbacks
Date: Fri, 23 Dec 2022 23:42:02 +0530	[thread overview]
Message-ID: <Y6XvcuFnqA8po5Ht@qemulion> (raw)

According to Documentation/filesystems/sysfs.rst, the show() callback
function of kobject attributes should strictly use sysfs_emit instead
of sprintf family functions.

Issue identified using the coccinelle device_attr_show.cocci script.

Signed-off-by: Deepak R Varma <drv@mailo.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 7eb8c39da366..f08b8731d6dd 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 sysfs_emit(buf, "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 sysfs_emit(buf, "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 sysfs_emit(buf, "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 sysfs_emit(buf, "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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%d\n", cs->disable_enc_msg);
 }

 static ssize_t disable_enclosure_messages_store(struct device *dev,
--
2.34.1




                 reply	other threads:[~2022-12-23 18:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=Y6XvcuFnqA8po5Ht@qemulion \
    --to=drv@mailo.com \
    --cc=hare@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=kumarpraveen@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ssengar@microsoft.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

all inboxes | Powered by JetHome®