From nobody Sat Sep 13 16:40:19 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F7A7C38142 for ; Wed, 1 Feb 2023 08:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbjBAIQS (ORCPT ); Wed, 1 Feb 2023 03:16:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbjBAIQP (ORCPT ); Wed, 1 Feb 2023 03:16:15 -0500 Received: from unicom146.biz-email.net (unicom146.biz-email.net [210.51.26.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716555CFE5 for ; Wed, 1 Feb 2023 00:16:13 -0800 (PST) Received: from ([60.208.111.195]) by unicom146.biz-email.net ((D)) with ASMTP (SSL) id XCS00108; Wed, 01 Feb 2023 16:16:08 +0800 Received: from localhost.localdomain (10.200.104.97) by jtjnmail201607.home.langchao.com (10.100.2.7) with Microsoft SMTP Server id 15.1.2507.16; Wed, 1 Feb 2023 16:16:09 +0800 From: Bo Liu To: CC: , , Bo Liu Subject: [PATCH] null_blk: convert sysfs snprintf to sysfs_emit Date: Wed, 1 Feb 2023 03:16:04 -0500 Message-ID: <20230201081604.3228-1-liubo03@inspur.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 X-Originating-IP: [10.200.104.97] tUid: 2023201161608d13dc716d0ef8b4f690272e9cc05d004 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- drivers/block/null_blk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c index 4c601ca9552a..7b79cda53c81 100644 --- a/drivers/block/null_blk/main.c +++ b/drivers/block/null_blk/main.c @@ -255,18 +255,18 @@ static inline struct nullb_device *to_nullb_device(st= ruct config_item *item) =20 static inline ssize_t nullb_device_uint_attr_show(unsigned int val, char *= page) { - return snprintf(page, PAGE_SIZE, "%u\n", val); + return sysfs_emit(page, "%u\n", val); } =20 static inline ssize_t nullb_device_ulong_attr_show(unsigned long val, char *page) { - return snprintf(page, PAGE_SIZE, "%lu\n", val); + return sysfs_emit(page, "%lu\n", val); } =20 static inline ssize_t nullb_device_bool_attr_show(bool val, char *page) { - return snprintf(page, PAGE_SIZE, "%u\n", val); + return sysfs_emit(page, "%u\n", val); } =20 static ssize_t nullb_device_uint_attr_store(unsigned int *val, @@ -627,7 +627,7 @@ nullb_group_drop_item(struct config_group *group, struc= t config_item *item) =20 static ssize_t memb_group_features_show(struct config_item *item, char *pa= ge) { - return snprintf(page, PAGE_SIZE, + return sysfs_emit(page, "badblocks,blocking,blocksize,cache_size," "completion_nsec,discard,home_node,hw_queue_depth," "irqmode,max_sectors,mbps,memory_backed,no_sched," --=20 2.27.0