Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2710092rdb; Tue, 12 Sep 2023 09:44:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErt3z1ZVas3U9ginIhQIfOfWREUPaNFEzwgEA18F68wfLKUiKrGiE52sROyTm7tDm+ubdr X-Received: by 2002:a05:6871:29d:b0:1d5:5d44:7404 with SMTP id i29-20020a056871029d00b001d55d447404mr49025oae.43.1694537051120; Tue, 12 Sep 2023 09:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694537051; cv=none; d=google.com; s=arc-20160816; b=P6YfR52q32tt4/+QtLZYBCK6NEj1KscPtVtw4WvAxpP7WXJ7LmT+mRmVgWBkCjULu9 3SbzulFXviLNGp0Q+X2hsRXBvH1lIbEY9k19CqW2AzaQlqNVtmpu+xdMM/b4rCNcGILv U4PsEH4vwy2/ZAyLh7kKo8/icTldDt/YBUtsUxlE9i6UAAO89ccnKOeMD4Tcx9tsuclq QkudguNkgd2koO2jZJyIUF2e4WhfgVGXo/He53yRo5tOI10CpDe84ojxB3Fw2SRAycE4 VIaOl2PQ5h0AIsib89FS2/Ao0ViilX4mT1oEvTaYdwSesdRzoCdHs8w93597fEcaiKtP yoaQ== 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.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id k4-20020a654644000000b00573e3b0d3e3si8062943pgr.408.2023.09.12.09.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 09:44:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; 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.36 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 pete.vger.email (Postfix) with ESMTP id AD1D380ACC40; Tue, 12 Sep 2023 08:07:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236264AbjILPHY (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 08:07:29 -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 pete.vger.email 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[]; -- 2.40.0.1.gaa8946217a0b