From nobody Thu Apr 2 19:50:00 2026 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 695B3C32771 for ; Wed, 21 Sep 2022 10:40:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231250AbiIUKkZ (ORCPT ); Wed, 21 Sep 2022 06:40:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230051AbiIUKkG (ORCPT ); Wed, 21 Sep 2022 06:40:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F824959F; Wed, 21 Sep 2022 03:40:05 -0700 (PDT) Date: Wed, 21 Sep 2022 10:40:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1663756802; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=w6aECWMoXmEq55sE/192A+mgoWXBLb2lLtjEAkHdJl0=; b=roUsfikotArZtMtsvMcSNK5oDUjCgWi2UzWFKk6Td5HCL17xxc+KPmpNKUkBuKgKGY3Y1l c5AaaQ42f1CgcqsuWfWwqDbCDEJT6FEihX5KmbzFggGf3i/L4zDdMkgq7BpCPJru6j/n6B 9s1x244hPz3XiyFh9YMZmUL4k2T8Ya+Mp/fI4xilHFa1ajR9NrVH11/YQntngwyoREfMSh /6apJse3cej+Bv4tVjIxNEOoo1To4T87Om/SuhQ/aCO2n4VYBEOD3HXDGe52K5BnrMJU0q lnzAekkVciFduLSZxduatfgYA9ktV0HrOnInzmqe5xU3VTmKyNHKSCLg4IvE1w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1663756802; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=w6aECWMoXmEq55sE/192A+mgoWXBLb2lLtjEAkHdJl0=; b=s1BFbDJTpMvu3czgY0lrAyt/UH+CzcXzzXi5KDq/GEKHx8K76rs57tdnWBBBnU3AXeUpdp +F+9ovq1MJi8jcBw== From: "tip-bot2 for Jules Irenge" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf/core: Convert snprintf() to scnprintf() Cc: Jules Irenge , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <166375680133.401.18293100258967657530.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: dca6344d7a77dd0501a73745f4a9fb1ee2bc9d7c Gitweb: https://git.kernel.org/tip/dca6344d7a77dd0501a73745f4a9fb1ee= 2bc9d7c Author: Jules Irenge AuthorDate: Sun, 18 Sep 2022 00:41:08 +01:00 Committer: Ingo Molnar CommitterDate: Wed, 21 Sep 2022 12:34:36 +02:00 perf/core: Convert snprintf() to scnprintf() Coccinelle reports a warning: WARNING: use scnprintf or sprintf This LWN article explains the rationale for this change: https: //lwn.net/Articles/69419/ Ie. snprintf() returns what *would* be the resulting length, while scnprintf() returns the actual length. Adding to that, there has also been some slow migration from snprintf to sc= nprintf, here's the shift in usage in the past 3.5 years, in all fs/ files: v5.0 v6.0-rc6 -------------------------------------- snprintf() uses: 63 213 scnprintf() uses: 374 186 No intended change in behavior. [ mingo: Improved the changelog & reviewed the usage sites. ] Signed-off-by: Jules Irenge Signed-off-by: Ingo Molnar --- kernel/events/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 7da5515..c07e9a3 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10952,7 +10952,7 @@ static ssize_t nr_addr_filters_show(struct device *= dev, { struct pmu *pmu =3D dev_get_drvdata(dev); =20 - return snprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters); + return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->nr_addr_filters); } DEVICE_ATTR_RO(nr_addr_filters); =20 @@ -10963,7 +10963,7 @@ type_show(struct device *dev, struct device_attribu= te *attr, char *page) { struct pmu *pmu =3D dev_get_drvdata(dev); =20 - return snprintf(page, PAGE_SIZE-1, "%d\n", pmu->type); + return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->type); } static DEVICE_ATTR_RO(type); =20 @@ -10974,7 +10974,7 @@ perf_event_mux_interval_ms_show(struct device *dev, { struct pmu *pmu =3D dev_get_drvdata(dev); =20 - return snprintf(page, PAGE_SIZE-1, "%d\n", pmu->hrtimer_interval_ms); + return scnprintf(page, PAGE_SIZE - 1, "%d\n", pmu->hrtimer_interval_ms); } =20 static DEFINE_MUTEX(mux_interval_mutex);