From patchwork Tue Sep 12 15:05:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 138278 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp502379vqx; Tue, 12 Sep 2023 08:52:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfBNf6t7ZI10bQRA7RBbOPkKrUbNCM0DPeXyO+Ozzt9THBXoCo9ctgtMOqHT7SFO2YrcJ9 X-Received: by 2002:a17:90a:2ca3:b0:273:4672:98b5 with SMTP id n32-20020a17090a2ca300b00273467298b5mr9821784pjd.42.1694533927687; Tue, 12 Sep 2023 08:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694533927; cv=none; d=google.com; s=arc-20160816; b=HzkpvGPXAT8epE5m8TNbumUfOkPMG35/s6KsJWyI7+iRlzzBysngj7rCiN5/lIsWd6 B0YFEWdZSAMpHBVghYEcdl5/yw+mic1ME0X4XAWRRlGb4MNE5nFqx+sNg4BxrUeA6D8s /UNVusbGCr73Vx09D7n39AoXftPE8OizYCou3EPkAXK0HaHuMAUKvYj/mlzqg596EQXj 6vSm3iRW++JkS8tqhiimhZFOKGYpISdeMcYuZgtG/M4QGlxWyWk4cykw+2Ww/IrerS9T 7XQ9+Qg8nTzUmyZ6mEqPOgl9b3XpuoRk/vzJfOxASzwr+n0bvihBuYoZOS7RX1GAs/Ts tSBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=8V4ZvePjdVrvb0+U5P3QIRKW+RKbbr7bAuKeDRfhJOs=; fh=bHBp+PJACSvucKAvnO3bf9DILRtfHT5RT33jsVWkQ4A=; b=PPP0gPjJ2Nqf74bLXUPLqXlzEIUyq7Pjo19Csv2a8Ok3l0F/Zn3uVr4oBuDU4BKqeA VgsXZl9JPABx28+wBCHPxjUbmP3Nhihv5Y/BGRChb2JXDr7GK8jwW2p57qQSjXYFGcIC nSOH0J60pfysh1MDwXKhOV5gKKWTG/RlqzfZw5vmMZ+oLGMKt0tPCE6vTvspa+pev3/7 owU2BftU/emy6wzUYsuXoxuPpq4LYNlZKDYqAv7JXYOo8Osimgxt3m7P6ElfAuNEa7h6 VL3rBkWxgHHsVQN2FmSjeB1Yl0lmxL6X9p05P0nXLjLnEKWWtQhhrmDN6RDg0odP/8Bi zgFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="I0YV/487"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id gt9-20020a17090af2c900b00263aff4ccf0si8153855pjb.3.2023.09.12.08.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 08:52:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="I0YV/487"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1175480F66B9; Tue, 12 Sep 2023 08:07:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236278AbjILPHY (ORCPT + 37 others); Tue, 12 Sep 2023 11:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236228AbjILPHV (ORCPT ); Tue, 12 Sep 2023 11:07:21 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 916B2E7F for ; Tue, 12 Sep 2023 08:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694531233; x=1726067233; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=5td1gKWCF+rIeOJVYGub5eI8NZKRZhGg2PyDn0c3U94=; b=I0YV/487jBgkDiNI55mMr/ujdroKXXLEuEinJIx61c1+GJHHnJ6VQ0aL 6BFDDwTE/mkEW2iVxvRyOmRyZuizcGHFDJ6Um216WGiWtUQYR/RhXb7tY MgweGSdaZWj+/sSqCPHgGINMlXMs93YukOtNNh1Q+T/rpTEcjkPiiWTy0 dZt4tkaj6KEXr8jeW/m/yf5xmBgRgCqiGbXHkYXZ7LxUwDgV+R+UZwW+l 0g9U5IkXi74gOskh6Y/SPUHExS+Y+ofco43Pab89JS1Ge70RTZ7H5pZ+S jbfjQDqA+eIJj+9vTGeiRHhIgNRaqmMYje66gYiSMn7AKtCu2hbwqcPkz g==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="409356428" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="409356428" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 08:05:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="858836454" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="858836454" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 12 Sep 2023 08:05:55 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5DC42248; Tue, 12 Sep 2023 18:05:54 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Luis Chamberlain Subject: [PATCH v1 1/6] params: Use sysfs_emit() to instead of scnprintf() Date: Tue, 12 Sep 2023 18:05:46 +0300 Message-Id: <20230912150551.401537-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Sep 2023 08:07:33 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776847607976090948 X-GMAIL-MSGID: 1776847607976090948 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: Andy Shevchenko --- kernel/params.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/params.c b/kernel/params.c index 2d4a0564697e..3efe6b98a600 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -222,8 +222,7 @@ char *parse_args(const char *doing, } \ int param_get_##name(char *buffer, const struct kernel_param *kp) \ { \ - return scnprintf(buffer, PAGE_SIZE, format "\n", \ - *((type *)kp->arg)); \ + return sysfs_emit(buffer, format "\n", *((type *)kp->arg)); \ } \ const struct kernel_param_ops param_ops_##name = { \ .set = param_set_##name, \ @@ -287,7 +286,7 @@ EXPORT_SYMBOL(param_set_charp); int param_get_charp(char *buffer, const struct kernel_param *kp) { - return scnprintf(buffer, PAGE_SIZE, "%s\n", *((char **)kp->arg)); + return sysfs_emit(buffer, "%s\n", *((char **)kp->arg)); } EXPORT_SYMBOL(param_get_charp); @@ -318,7 +317,7 @@ EXPORT_SYMBOL(param_set_bool); int param_get_bool(char *buffer, const struct kernel_param *kp) { /* Y and N chosen as being relatively non-coder friendly */ - return sprintf(buffer, "%c\n", *(bool *)kp->arg ? 'Y' : 'N'); + return sysfs_emit(buffer, "%c\n", *(bool *)kp->arg ? 'Y' : 'N'); } EXPORT_SYMBOL(param_get_bool); @@ -377,7 +376,7 @@ EXPORT_SYMBOL(param_set_invbool); int param_get_invbool(char *buffer, const struct kernel_param *kp) { - return sprintf(buffer, "%c\n", (*(bool *)kp->arg) ? 'N' : 'Y'); + return sysfs_emit(buffer, "%c\n", (*(bool *)kp->arg) ? 'N' : 'Y'); } EXPORT_SYMBOL(param_get_invbool); @@ -525,7 +524,8 @@ EXPORT_SYMBOL(param_set_copystring); int param_get_string(char *buffer, const struct kernel_param *kp) { const struct kparam_string *kps = kp->str; - return scnprintf(buffer, PAGE_SIZE, "%s\n", kps->string); + + return sysfs_emit(buffer, "%s\n", kps->string); } EXPORT_SYMBOL(param_get_string); @@ -859,7 +859,7 @@ ssize_t __modver_version_show(struct module_attribute *mattr, struct module_version_attribute *vattr = container_of(mattr, struct module_version_attribute, mattr); - return scnprintf(buf, PAGE_SIZE, "%s\n", vattr->version); + return sysfs_emit(buf, "%s\n", vattr->version); } extern const struct module_version_attribute __start___modver[];