vhost-scsi: convert sysfs snprintf and sprintf to sysfs_emit
authorBo Liu <liubo03@inspur.com>
Sun, 29 Jan 2023 09:11:45 +0000 (04:11 -0500)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 21 Feb 2023 00:26:58 +0000 (19:26 -0500)
Follow the advice of the Documentation/filesystems/sysfs.rst
and show() should only use sysfs_emit() or sysfs_emit_at()
when formatting the value to be returned to user space.

Signed-off-by: Bo Liu <liubo03@inspur.com>
Message-Id: <20230129091145.2837-1-liubo03@inspur.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/scsi.c

index d5ecb88..b244e7c 100644 (file)
@@ -2105,7 +2105,7 @@ static ssize_t vhost_scsi_tpg_attrib_fabric_prot_type_show(
        struct vhost_scsi_tpg *tpg = container_of(se_tpg,
                                struct vhost_scsi_tpg, se_tpg);
 
-       return sprintf(page, "%d\n", tpg->tv_fabric_prot_type);
+       return sysfs_emit(page, "%d\n", tpg->tv_fabric_prot_type);
 }
 
 CONFIGFS_ATTR(vhost_scsi_tpg_attrib_, fabric_prot_type);
@@ -2215,7 +2215,7 @@ static ssize_t vhost_scsi_tpg_nexus_show(struct config_item *item, char *page)
                mutex_unlock(&tpg->tv_tpg_mutex);
                return -ENODEV;
        }
-       ret = snprintf(page, PAGE_SIZE, "%s\n",
+       ret = sysfs_emit(page, "%s\n",
                        tv_nexus->tvn_se_sess->se_node_acl->initiatorname);
        mutex_unlock(&tpg->tv_tpg_mutex);
 
@@ -2440,7 +2440,7 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
 static ssize_t
 vhost_scsi_wwn_version_show(struct config_item *item, char *page)
 {
-       return sprintf(page, "TCM_VHOST fabric module %s on %s/%s"
+       return sysfs_emit(page, "TCM_VHOST fabric module %s on %s/%s"
                "on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname,
                utsname()->machine);
 }