From patchwork Mon Dec 5 11:03:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ye.xingchen@zte.com.cn X-Patchwork-Id: 29643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2182356wrr; Mon, 5 Dec 2022 03:05:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf56+1+dYZ2IJEElTsxsUAh3LGYRS1Ef3a9XGm2oo6d6f8KFHQLOZ2dcSuIFO12whAkYKtwt X-Received: by 2002:a17:906:4914:b0:7c0:93e6:9f18 with SMTP id b20-20020a170906491400b007c093e69f18mr21670156ejq.350.1670238334548; Mon, 05 Dec 2022 03:05:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670238334; cv=none; d=google.com; s=arc-20160816; b=rgK5YS0njwl7xor41sYukfNLn5y5TFrpwAivInsUI/BJ0jZGAGKUPbPYG6F8MDVSXu oF8yKGK4/4RYDiZStoSyFByYYJ0DBEDx8Po8jKSzYblLLx5iifkZSqbaNzOOxcFABj/0 jjZIdH9ilBlxHGhPByke2xab+/2r5IipCGSOfZsU/xGPvdqTMklLuEzf2p6UcLMgh43V PhdCPRrCtnkPKuN3kWtRBqlDM09hZhKzuglfLbOvKm10MRVmhrRNI6L50/PAntzD1JO4 T5yLhTtEtDabqKwQgakWuzICh1Abw+bNTCBjHJy/Qst+8oXLOHC3Aldl4EaC4ixja7a3 AszQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=tE8ngmYr0+KaKldq3jkzUNeUoyrpStstR2TVjfsUNzU=; b=xb6hHAVbCnjjAqbgE2ftuTQHYyxKhvMpgRnFV0nSvq9coLH5t2Vc8PkpIKArFUKx8m DqTuwcllUfzFsAF95T8pnOKwTG935xYOe+Lxt6qXlS9Bse8IQCB8jintck8NGVzBrZiv cFKb/LJrs26gqv3ODxFLyqGCkqM3FOEY2153H5UuY82rnhPM0OP/FnbsFVHzlDwv0ETm 5+Jvyka8Pd3Z+H1gxzhQIzPqvWtTwlD9ap1RrBQrDIx9Uu9eUY/jVpmIM92gqUZb6Iul tGOW9nYDlXxRU3l62c/EEze2OMwFMSHXWPwcpqohkC++YviyPLr4MTyL2XrqkZx+s1X9 DbRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ce11-20020a170906b24b00b0078356aaeb63si9086766ejb.288.2022.12.05.03.05.09; Mon, 05 Dec 2022 03:05:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231156AbiLELD4 (ORCPT + 99 others); Mon, 5 Dec 2022 06:03:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229982AbiLELDx (ORCPT ); Mon, 5 Dec 2022 06:03:53 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B227223 for ; Mon, 5 Dec 2022 03:03:51 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4NQgdx22Mbz4y0vM; Mon, 5 Dec 2022 19:03:49 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2B5B3b3Y053222; Mon, 5 Dec 2022 19:03:37 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Mon, 5 Dec 2022 19:03:39 +0800 (CST) Date: Mon, 5 Dec 2022 19:03:39 +0800 (CST) X-Zmail-TransId: 2af9638dd00b38ebad33 X-Mailer: Zmail v1.0 Message-ID: <202212051903396321367@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , Subject: =?utf-8?q?=5BPATCH=5D_orangefs=3A_use_sysfs=5Femit=28=29_to_instead?= =?utf-8?q?_of_scnprintf=28=29?= X-MAIL: mse-fl2.zte.com.cn 2B5B3b3Y053222 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 638DD015.001 by FangMail milter! X-FangMail-Envelope: 1670238229/4NQgdx22Mbz4y0vM/638DD015.001/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638DD015.001/4NQgdx22Mbz4y0vM X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751371832078867560?= X-GMAIL-MSGID: =?utf-8?q?1751371832078867560?= From: ye xingchen 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: ye xingchen --- fs/orangefs/orangefs-sysfs.c | 45 ++++++++---------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/fs/orangefs/orangefs-sysfs.c b/fs/orangefs/orangefs-sysfs.c index de80b62553bb..c89f16052e92 100644 --- a/fs/orangefs/orangefs-sysfs.c +++ b/fs/orangefs/orangefs-sysfs.c @@ -217,38 +217,23 @@ static ssize_t sysfs_int_show(struct kobject *kobj, if (!strcmp(kobj->name, ORANGEFS_KOBJ_ID)) { if (!strcmp(attr->attr.name, "op_timeout_secs")) { - rc = scnprintf(buf, - PAGE_SIZE, - "%d\n", - op_timeout_secs); + rc = sysfs_emit(buf, "%d\n", op_timeout_secs); goto out; } else if (!strcmp(attr->attr.name, "slot_timeout_secs")) { - rc = scnprintf(buf, - PAGE_SIZE, - "%d\n", - slot_timeout_secs); + rc = sysfs_emit(buf, "%d\n", slot_timeout_secs); goto out; } else if (!strcmp(attr->attr.name, "cache_timeout_msecs")) { - rc = scnprintf(buf, - PAGE_SIZE, - "%d\n", - orangefs_cache_timeout_msecs); + rc = sysfs_emit(buf, "%d\n", orangefs_cache_timeout_msecs); goto out; } else if (!strcmp(attr->attr.name, "dcache_timeout_msecs")) { - rc = scnprintf(buf, - PAGE_SIZE, - "%d\n", - orangefs_dcache_timeout_msecs); + rc = sysfs_emit(buf, "%d\n", orangefs_dcache_timeout_msecs); goto out; } else if (!strcmp(attr->attr.name, "getattr_timeout_msecs")) { - rc = scnprintf(buf, - PAGE_SIZE, - "%d\n", - orangefs_getattr_timeout_msecs); + rc = sysfs_emit(buf, "%d\n", orangefs_getattr_timeout_msecs); goto out; } else { goto out; @@ -256,16 +241,10 @@ static ssize_t sysfs_int_show(struct kobject *kobj, } else if (!strcmp(kobj->name, STATS_KOBJ_ID)) { if (!strcmp(attr->attr.name, "reads")) { - rc = scnprintf(buf, - PAGE_SIZE, - "%lu\n", - orangefs_stats.reads); + rc = sysfs_emit(buf, "%lu\n", orangefs_stats.reads); goto out; } else if (!strcmp(attr->attr.name, "writes")) { - rc = scnprintf(buf, - PAGE_SIZE, - "%lu\n", - orangefs_stats.writes); + rc = sysfs_emit(buf, "%lu\n", orangefs_stats.writes); goto out; } else { goto out; @@ -497,21 +476,17 @@ static ssize_t sysfs_service_op_show(struct kobject *kobj, if (strcmp(kobj->name, PC_KOBJ_ID)) { if (new_op->upcall.req.param.op == ORANGEFS_PARAM_REQUEST_OP_READAHEAD_COUNT_SIZE) { - rc = scnprintf(buf, PAGE_SIZE, "%d %d\n", + rc = sysfs_emit(buf, "%d %d\n", (int)new_op->downcall.resp.param.u. value32[0], (int)new_op->downcall.resp.param.u. value32[1]); } else { - rc = scnprintf(buf, PAGE_SIZE, "%d\n", + rc = sysfs_emit(buf, "%d\n", (int)new_op->downcall.resp.param.u.value64); } } else { - rc = scnprintf( - buf, - PAGE_SIZE, - "%s", - new_op->downcall.resp.perf_count.buffer); + rc = sysfs_emit(buf, "%s", new_op->downcall.resp.perf_count.buffer); } }