diff mbox series

[linux-next] scsi: target: use sysfs_emit() to instead of snprintf()

Message ID 20220927113437.259529-1-zhang.songyi@zte.com.cn (mailing list archive)
State Rejected
Headers show
Series [linux-next] scsi: target: use sysfs_emit() to instead of snprintf() | expand

Commit Message

zhangsongyi.cgel@gmail.com Sept. 27, 2022, 11:34 a.m. UTC
From: zhang songyi <zhang.songyi@zte.com.cn>

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.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: zhang songyi <zhang.songyi@zte.com.cn>
---
 drivers/target/iscsi/iscsi_target_stat.c | 94 ++++++++++++------------
 1 file changed, 47 insertions(+), 47 deletions(-)

Comments

kernel test robot Sept. 29, 2022, 7:48 p.m. UTC | #1
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20220923]

url:    https://github.com/intel-lab-lkp/linux/commits/zhangsongyi-cgel-gmail-com/scsi-target-use-sysfs_emit-to-instead-of-snprintf/20220927-193709
base:    aaa11ce2ffc84166d11c4d2ac88c3fcf75425fbd
config: i386-randconfig-a015
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/df2a8cf8246502fbfbe578ff9f00df9523d1641a
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review zhangsongyi-cgel-gmail-com/scsi-target-use-sysfs_emit-to-instead-of-snprintf/20220927-193709
        git checkout df2a8cf8246502fbfbe578ff9f00df9523d1641a
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/target/iscsi/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/target/iscsi/iscsi_target_stat.c:53:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n",
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:60:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n", ISCSI_DRAFT20_VERSION);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:66:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n", ISCSI_DRAFT20_VERSION);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:72:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n",
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:79:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n", ISCSI_INST_NUM_NODES);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:85:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n",
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:102:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n", sess_err_count);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:111:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n",
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:121:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%s\n",
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:129:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n", ISCSI_DISCONTINUITY_TIME);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:135:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%s\n", ISCSI_INST_DESCR);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:141:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "Datera, Inc. iSCSI-Target\n");
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:147:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%s\n", ISCSIT_VERSION);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:199:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n",
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:209:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n", sess_err->digest_errors);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:218:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n", sess_err->cxn_timeout_errors);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:227:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n", sess_err->pdu_format_errors);
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:261:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n",
                  ^
   drivers/target/iscsi/iscsi_target_stat.c:268:9: error: implicit declaration of function 'sysfs_emit' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           return sysfs_emit(page, "%u\n", ISCSI_NODE_INDEX);
                  ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   20 errors generated.


vim +/sysfs_emit +53 drivers/target/iscsi/iscsi_target_stat.c

    49	
    50	static ssize_t iscsi_stat_instance_inst_show(struct config_item *item,
    51			char *page)
    52	{
  > 53		return sysfs_emit(page, "%u\n",
    54				iscsi_instance_tiqn(item)->tiqn_index);
    55	}
    56
diff mbox series

Patch

diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c
index 367c6468b8e1..64a3fa7965a6 100644
--- a/drivers/target/iscsi/iscsi_target_stat.c
+++ b/drivers/target/iscsi/iscsi_target_stat.c
@@ -50,39 +50,39 @@  static struct iscsi_tiqn *iscsi_instance_tiqn(struct config_item *item)
 static ssize_t iscsi_stat_instance_inst_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n",
+	return sysfs_emit(page, "%u\n",
 			iscsi_instance_tiqn(item)->tiqn_index);
 }
 
 static ssize_t iscsi_stat_instance_min_ver_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DRAFT20_VERSION);
+	return sysfs_emit(page, "%u\n", ISCSI_DRAFT20_VERSION);
 }
 
 static ssize_t iscsi_stat_instance_max_ver_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DRAFT20_VERSION);
+	return sysfs_emit(page, "%u\n", ISCSI_DRAFT20_VERSION);
 }
 
 static ssize_t iscsi_stat_instance_portals_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n",
+	return sysfs_emit(page, "%u\n",
 			iscsi_instance_tiqn(item)->tiqn_num_tpg_nps);
 }
 
 static ssize_t iscsi_stat_instance_nodes_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_INST_NUM_NODES);
+	return sysfs_emit(page, "%u\n", ISCSI_INST_NUM_NODES);
 }
 
 static ssize_t iscsi_stat_instance_sessions_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n",
+	return sysfs_emit(page, "%u\n",
 		iscsi_instance_tiqn(item)->tiqn_nsessions);
 }
 
@@ -99,7 +99,7 @@  static ssize_t iscsi_stat_instance_fail_sess_show(struct config_item *item,
 			  sess_err->pdu_format_errors);
 	spin_unlock_bh(&sess_err->lock);
 
-	return snprintf(page, PAGE_SIZE, "%u\n", sess_err_count);
+	return sysfs_emit(page, "%u\n", sess_err_count);
 }
 
 static ssize_t iscsi_stat_instance_fail_type_show(struct config_item *item,
@@ -108,7 +108,7 @@  static ssize_t iscsi_stat_instance_fail_type_show(struct config_item *item,
 	struct iscsi_tiqn *tiqn = iscsi_instance_tiqn(item);
 	struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats;
 
-	return snprintf(page, PAGE_SIZE, "%u\n",
+	return sysfs_emit(page, "%u\n",
 			sess_err->last_sess_failure_type);
 }
 
@@ -118,7 +118,7 @@  static ssize_t iscsi_stat_instance_fail_rem_name_show(struct config_item *item,
 	struct iscsi_tiqn *tiqn = iscsi_instance_tiqn(item);
 	struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats;
 
-	return snprintf(page, PAGE_SIZE, "%s\n",
+	return sysfs_emit(page, "%s\n",
 			sess_err->last_sess_fail_rem_name[0] ?
 			sess_err->last_sess_fail_rem_name : NONE);
 }
@@ -126,25 +126,25 @@  static ssize_t iscsi_stat_instance_fail_rem_name_show(struct config_item *item,
 static ssize_t iscsi_stat_instance_disc_time_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DISCONTINUITY_TIME);
+	return sysfs_emit(page, "%u\n", ISCSI_DISCONTINUITY_TIME);
 }
 
 static ssize_t iscsi_stat_instance_description_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%s\n", ISCSI_INST_DESCR);
+	return sysfs_emit(page, "%s\n", ISCSI_INST_DESCR);
 }
 
 static ssize_t iscsi_stat_instance_vendor_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "Datera, Inc. iSCSI-Target\n");
+	return sysfs_emit(page, "Datera, Inc. iSCSI-Target\n");
 }
 
 static ssize_t iscsi_stat_instance_version_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%s\n", ISCSIT_VERSION);
+	return sysfs_emit(page, "%s\n", ISCSIT_VERSION);
 }
 
 CONFIGFS_ATTR_RO(iscsi_stat_instance_, inst);
@@ -196,7 +196,7 @@  static struct iscsi_tiqn *iscsi_sess_err_tiqn(struct config_item *item)
 static ssize_t iscsi_stat_sess_err_inst_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n",
+	return sysfs_emit(page, "%u\n",
 		iscsi_sess_err_tiqn(item)->tiqn_index);
 }
 
@@ -206,7 +206,7 @@  static ssize_t iscsi_stat_sess_err_digest_errors_show(struct config_item *item,
 	struct iscsi_tiqn *tiqn = iscsi_sess_err_tiqn(item);
 	struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats;
 
-	return snprintf(page, PAGE_SIZE, "%u\n", sess_err->digest_errors);
+	return sysfs_emit(page, "%u\n", sess_err->digest_errors);
 }
 
 static ssize_t iscsi_stat_sess_err_cxn_errors_show(struct config_item *item,
@@ -215,7 +215,7 @@  static ssize_t iscsi_stat_sess_err_cxn_errors_show(struct config_item *item,
 	struct iscsi_tiqn *tiqn = iscsi_sess_err_tiqn(item);
 	struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats;
 
-	return snprintf(page, PAGE_SIZE, "%u\n", sess_err->cxn_timeout_errors);
+	return sysfs_emit(page, "%u\n", sess_err->cxn_timeout_errors);
 }
 
 static ssize_t iscsi_stat_sess_err_format_errors_show(struct config_item *item,
@@ -224,7 +224,7 @@  static ssize_t iscsi_stat_sess_err_format_errors_show(struct config_item *item,
 	struct iscsi_tiqn *tiqn = iscsi_sess_err_tiqn(item);
 	struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats;
 
-	return snprintf(page, PAGE_SIZE, "%u\n", sess_err->pdu_format_errors);
+	return sysfs_emit(page, "%u\n", sess_err->pdu_format_errors);
 }
 
 CONFIGFS_ATTR_RO(iscsi_stat_sess_err_, inst);
@@ -258,14 +258,14 @@  static struct iscsi_tiqn *iscsi_tgt_attr_tiqn(struct config_item *item)
 static ssize_t iscsi_stat_tgt_attr_inst_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n",
+	return sysfs_emit(page, "%u\n",
 			iscsi_tgt_attr_tiqn(item)->tiqn_index);
 }
 
 static ssize_t iscsi_stat_tgt_attr_indx_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX);
+	return sysfs_emit(page, "%u\n", ISCSI_NODE_INDEX);
 }
 
 static ssize_t iscsi_stat_tgt_attr_login_fails_show(struct config_item *item,
@@ -281,7 +281,7 @@  static ssize_t iscsi_stat_tgt_attr_login_fails_show(struct config_item *item,
 			lstat->other_fails);
 	spin_unlock(&lstat->lock);
 
-	return snprintf(page, PAGE_SIZE, "%u\n", fail_count);
+	return sysfs_emit(page, "%u\n", fail_count);
 }
 
 static ssize_t iscsi_stat_tgt_attr_last_fail_time_show(struct config_item *item,
@@ -297,7 +297,7 @@  static ssize_t iscsi_stat_tgt_attr_last_fail_time_show(struct config_item *item,
 				INITIAL_JIFFIES) * 100 / HZ) : 0;
 	spin_unlock(&lstat->lock);
 
-	return snprintf(page, PAGE_SIZE, "%u\n", last_fail_time);
+	return sysfs_emit(page, "%u\n", last_fail_time);
 }
 
 static ssize_t iscsi_stat_tgt_attr_last_fail_type_show(struct config_item *item,
@@ -311,7 +311,7 @@  static ssize_t iscsi_stat_tgt_attr_last_fail_type_show(struct config_item *item,
 	last_fail_type = lstat->last_fail_type;
 	spin_unlock(&lstat->lock);
 
-	return snprintf(page, PAGE_SIZE, "%u\n", last_fail_type);
+	return sysfs_emit(page, "%u\n", last_fail_type);
 }
 
 static ssize_t iscsi_stat_tgt_attr_fail_intr_name_show(struct config_item *item,
@@ -326,7 +326,7 @@  static ssize_t iscsi_stat_tgt_attr_fail_intr_name_show(struct config_item *item,
 				lstat->last_intr_fail_name : NONE);
 	spin_unlock(&lstat->lock);
 
-	return snprintf(page, PAGE_SIZE, "%s\n", buf);
+	return sysfs_emit(page, "%s\n", buf);
 }
 
 static ssize_t iscsi_stat_tgt_attr_fail_intr_addr_type_show(struct config_item *item,
@@ -338,9 +338,9 @@  static ssize_t iscsi_stat_tgt_attr_fail_intr_addr_type_show(struct config_item *
 
 	spin_lock(&lstat->lock);
 	if (lstat->last_intr_fail_ip_family == AF_INET6)
-		ret = snprintf(page, PAGE_SIZE, "ipv6\n");
+		ret = sysfs_emit(page, "ipv6\n");
 	else
-		ret = snprintf(page, PAGE_SIZE, "ipv4\n");
+		ret = sysfs_emit(page, "ipv4\n");
 	spin_unlock(&lstat->lock);
 
 	return ret;
@@ -354,7 +354,7 @@  static ssize_t iscsi_stat_tgt_attr_fail_intr_addr_show(struct config_item *item,
 	int ret;
 
 	spin_lock(&lstat->lock);
-	ret = snprintf(page, PAGE_SIZE, "%pISc\n", &lstat->last_intr_fail_sockaddr);
+	ret = sysfs_emit(page, "%pISc\n", &lstat->last_intr_fail_sockaddr);
 	spin_unlock(&lstat->lock);
 
 	return ret;
@@ -398,14 +398,14 @@  static struct iscsi_tiqn *iscsi_login_stat_tiqn(struct config_item *item)
 
 static ssize_t iscsi_stat_login_inst_show(struct config_item *item, char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n",
+	return sysfs_emit(page, "%u\n",
 		iscsi_login_stat_tiqn(item)->tiqn_index);
 }
 
 static ssize_t iscsi_stat_login_indx_show(struct config_item *item,
 		char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX);
+	return sysfs_emit(page, "%u\n", ISCSI_NODE_INDEX);
 }
 
 static ssize_t iscsi_stat_login_accepts_show(struct config_item *item,
@@ -416,7 +416,7 @@  static ssize_t iscsi_stat_login_accepts_show(struct config_item *item,
 	ssize_t ret;
 
 	spin_lock(&lstat->lock);
-	ret = snprintf(page, PAGE_SIZE, "%u\n", lstat->accepts);
+	ret = sysfs_emit(page, "%u\n", lstat->accepts);
 	spin_unlock(&lstat->lock);
 
 	return ret;
@@ -430,7 +430,7 @@  static ssize_t iscsi_stat_login_other_fails_show(struct config_item *item,
 	ssize_t ret;
 
 	spin_lock(&lstat->lock);
-	ret = snprintf(page, PAGE_SIZE, "%u\n", lstat->other_fails);
+	ret = sysfs_emit(page, "%u\n", lstat->other_fails);
 	spin_unlock(&lstat->lock);
 
 	return ret;
@@ -444,7 +444,7 @@  static ssize_t iscsi_stat_login_redirects_show(struct config_item *item,
 	ssize_t ret;
 
 	spin_lock(&lstat->lock);
-	ret = snprintf(page, PAGE_SIZE, "%u\n", lstat->redirects);
+	ret = sysfs_emit(page, "%u\n", lstat->redirects);
 	spin_unlock(&lstat->lock);
 
 	return ret;
@@ -458,7 +458,7 @@  static ssize_t iscsi_stat_login_authorize_fails_show(struct config_item *item,
 	ssize_t ret;
 
 	spin_lock(&lstat->lock);
-	ret = snprintf(page, PAGE_SIZE, "%u\n", lstat->authorize_fails);
+	ret = sysfs_emit(page, "%u\n", lstat->authorize_fails);
 	spin_unlock(&lstat->lock);
 
 	return ret;
@@ -472,7 +472,7 @@  static ssize_t iscsi_stat_login_authenticate_fails_show(
 	ssize_t ret;
 
 	spin_lock(&lstat->lock);
-	ret = snprintf(page, PAGE_SIZE, "%u\n", lstat->authenticate_fails);
+	ret = sysfs_emit(page, "%u\n", lstat->authenticate_fails);
 	spin_unlock(&lstat->lock);
 
 	return ret;
@@ -486,7 +486,7 @@  static ssize_t iscsi_stat_login_negotiate_fails_show(struct config_item *item,
 	ssize_t ret;
 
 	spin_lock(&lstat->lock);
-	ret = snprintf(page, PAGE_SIZE, "%u\n", lstat->negotiate_fails);
+	ret = sysfs_emit(page, "%u\n", lstat->negotiate_fails);
 	spin_unlock(&lstat->lock);
 
 	return ret;
@@ -530,13 +530,13 @@  static struct iscsi_tiqn *iscsi_logout_stat_tiqn(struct config_item *item)
 
 static ssize_t iscsi_stat_logout_inst_show(struct config_item *item, char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n",
+	return sysfs_emit(page, "%u\n",
 		iscsi_logout_stat_tiqn(item)->tiqn_index);
 }
 
 static ssize_t iscsi_stat_logout_indx_show(struct config_item *item, char *page)
 {
-	return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX);
+	return sysfs_emit(page, "%u\n", ISCSI_NODE_INDEX);
 }
 
 static ssize_t iscsi_stat_logout_normal_logouts_show(struct config_item *item,
@@ -545,7 +545,7 @@  static ssize_t iscsi_stat_logout_normal_logouts_show(struct config_item *item,
 	struct iscsi_tiqn *tiqn = iscsi_logout_stat_tiqn(item);
 	struct iscsi_logout_stats *lstats = &tiqn->logout_stats;
 
-	return snprintf(page, PAGE_SIZE, "%u\n", lstats->normal_logouts);
+	return sysfs_emit(page, "%u\n", lstats->normal_logouts);
 }
 
 static ssize_t iscsi_stat_logout_abnormal_logouts_show(struct config_item *item,
@@ -554,7 +554,7 @@  static ssize_t iscsi_stat_logout_abnormal_logouts_show(struct config_item *item,
 	struct iscsi_tiqn *tiqn = iscsi_logout_stat_tiqn(item);
 	struct iscsi_logout_stats *lstats = &tiqn->logout_stats;
 
-	return snprintf(page, PAGE_SIZE, "%u\n", lstats->abnormal_logouts);
+	return sysfs_emit(page, "%u\n", lstats->abnormal_logouts);
 }
 
 CONFIGFS_ATTR_RO(iscsi_stat_logout_, inst);
@@ -592,7 +592,7 @@  static ssize_t iscsi_stat_sess_inst_show(struct config_item *item, char *page)
 	struct iscsi_tiqn *tiqn = container_of(wwn,
 			struct iscsi_tiqn, tiqn_wwn);
 
-	return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index);
+	return sysfs_emit(page, "%u\n", tiqn->tiqn_index);
 }
 
 static ssize_t iscsi_stat_sess_node_show(struct config_item *item, char *page)
@@ -608,7 +608,7 @@  static ssize_t iscsi_stat_sess_node_show(struct config_item *item, char *page)
 	if (se_sess) {
 		sess = se_sess->fabric_sess_ptr;
 		if (sess)
-			ret = snprintf(page, PAGE_SIZE, "%u\n",
+			ret = sysfs_emit(page, "%u\n",
 				sess->sess_ops->SessionType ? 0 : ISCSI_NODE_INDEX);
 	}
 	spin_unlock_bh(&se_nacl->nacl_sess_lock);
@@ -629,7 +629,7 @@  static ssize_t iscsi_stat_sess_indx_show(struct config_item *item, char *page)
 	if (se_sess) {
 		sess = se_sess->fabric_sess_ptr;
 		if (sess)
-			ret = snprintf(page, PAGE_SIZE, "%u\n",
+			ret = sysfs_emit(page, "%u\n",
 					sess->session_index);
 	}
 	spin_unlock_bh(&se_nacl->nacl_sess_lock);
@@ -651,7 +651,7 @@  static ssize_t iscsi_stat_sess_cmd_pdus_show(struct config_item *item,
 	if (se_sess) {
 		sess = se_sess->fabric_sess_ptr;
 		if (sess)
-			ret = snprintf(page, PAGE_SIZE, "%lu\n",
+			ret = sysfs_emit(page, "%lu\n",
 				       atomic_long_read(&sess->cmd_pdus));
 	}
 	spin_unlock_bh(&se_nacl->nacl_sess_lock);
@@ -673,7 +673,7 @@  static ssize_t iscsi_stat_sess_rsp_pdus_show(struct config_item *item,
 	if (se_sess) {
 		sess = se_sess->fabric_sess_ptr;
 		if (sess)
-			ret = snprintf(page, PAGE_SIZE, "%lu\n",
+			ret = sysfs_emit(page, "%lu\n",
 				       atomic_long_read(&sess->rsp_pdus));
 	}
 	spin_unlock_bh(&se_nacl->nacl_sess_lock);
@@ -695,7 +695,7 @@  static ssize_t iscsi_stat_sess_txdata_octs_show(struct config_item *item,
 	if (se_sess) {
 		sess = se_sess->fabric_sess_ptr;
 		if (sess)
-			ret = snprintf(page, PAGE_SIZE, "%lu\n",
+			ret = sysfs_emit(page, "%lu\n",
 				       atomic_long_read(&sess->tx_data_octets));
 	}
 	spin_unlock_bh(&se_nacl->nacl_sess_lock);
@@ -717,7 +717,7 @@  static ssize_t iscsi_stat_sess_rxdata_octs_show(struct config_item *item,
 	if (se_sess) {
 		sess = se_sess->fabric_sess_ptr;
 		if (sess)
-			ret = snprintf(page, PAGE_SIZE, "%lu\n",
+			ret = sysfs_emit(page, "%lu\n",
 				       atomic_long_read(&sess->rx_data_octets));
 	}
 	spin_unlock_bh(&se_nacl->nacl_sess_lock);
@@ -739,7 +739,7 @@  static ssize_t iscsi_stat_sess_conn_digest_errors_show(struct config_item *item,
 	if (se_sess) {
 		sess = se_sess->fabric_sess_ptr;
 		if (sess)
-			ret = snprintf(page, PAGE_SIZE, "%lu\n",
+			ret = sysfs_emit(page, "%lu\n",
 				       atomic_long_read(&sess->conn_digest_errors));
 	}
 	spin_unlock_bh(&se_nacl->nacl_sess_lock);
@@ -761,7 +761,7 @@  static ssize_t iscsi_stat_sess_conn_timeout_errors_show(
 	if (se_sess) {
 		sess = se_sess->fabric_sess_ptr;
 		if (sess)
-			ret = snprintf(page, PAGE_SIZE, "%lu\n",
+			ret = sysfs_emit(page, "%lu\n",
 				       atomic_long_read(&sess->conn_timeout_errors));
 	}
 	spin_unlock_bh(&se_nacl->nacl_sess_lock);