From nobody Thu Apr 2 22:05:13 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEEC9389115 for ; Thu, 26 Mar 2026 14:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774535189; cv=none; b=WRp/ySY1RClHbwAi4VC5V+7N54u9accRc/JrtWwahHfR35Px/CoxyruB4lg4qWaQliic04Ep0l9yrfdDlWj/KFUAxpoCJM6VL336ln/Kj+NQvez/UssJMUaKe0A9kW+cwRdYJkGpp74g3o6nIwPCFeTdsXH1TUmVuZ2nZuf33tY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774535189; c=relaxed/simple; bh=9WBcVw9Mn5JnV5u0u1fcUdkgNqAM6vpU1uJiOvoVRNg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=W3ucmESJ8Ewe0vCOInnRaeXsK64Lb5+O2g+m6SEi+Ak37VOI4Qkv5/Fq1BTy4LG3Mj8/8bA26rk5yBnGtGMuWVL5M/UrvF1wd7RBFkMgu98wGxNyYZpavSDjEwzhPHGmyi9fQ31xK7eO43P9Bl2OxqQejJxZP8A9+CWf2yRsmL8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bTMQAqnc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bTMQAqnc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92D32C19424; Thu, 26 Mar 2026 14:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774535189; bh=9WBcVw9Mn5JnV5u0u1fcUdkgNqAM6vpU1uJiOvoVRNg=; h=Date:From:To:Cc:Subject:References:From; b=bTMQAqncGl4tf04+jiEKAOmjouRyFA6igVBi0YljAaydusdDK91xx6NieC0VjEQdh tb0JzmhARVP+YbgdRCzN817B2MQQzAedkMOALbTl9VnQSA4vMdta/3p+HAFwmnYe4k sa7qsd3qbqIDBjDG1djlhIgZj1N3lec4BAMJmPLYgNYQjRBZg/TYdcTBzUcXQ96w2s n25zWH8/7nChJmI4l+cGce03qPVqBWjUx+fqP7cu/ydXN7H+NG+hALdEearsKjDUHh JCl1JyB3cU0UNXqIVmoJwGKxOX+QhSp0RwyXvhInORaGPfCyxx7FB6mf1HvdRTPEf6 bHgXL0rLJY4fQ== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1w5lg4-0000000Du9y-1HhZ; Thu, 26 Mar 2026 10:27:16 -0400 Message-ID: <20260326142716.158410157@kernel.org> User-Agent: quilt/0.69 Date: Thu, 26 Mar 2026 10:26:57 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Anna Schumaker , Chuck Lever , Simon Horman , Yury Norov , Randy Dunlap , Jeff Layton , Arnd Bergmann , Andy Shevchenko Subject: [for-next][PATCH 01/13] tracing: move __printf() attribute on __ftrace_vbprintk() References: <20260326142656.794462952@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann The sunrpc change to use trace_printk() for debugging caused a new warning for every instance of dprintk() in some configurations, when -Wformat-security is enabled: fs/nfs/getroot.c: In function 'nfs_get_root': fs/nfs/getroot.c:90:17: error: format not a string literal and no format ar= guments [-Werror=3Dformat-security] 90 | nfs_errorf(fc, "NFS: Couldn't getattr on root"); I've been slowly chipping away at those warnings over time with the intention of enabling them by default in the future. While I could not figure out why this only happens for this one instance, I see that the __trace_bprintk() function is always called with a local variable as the format string, rather than a literal. Move the __printf(2,3) annotation on this function from the declaration to the caller. As this is can only be validated for literals, the attribute on the declaration causes the warnings every time, but removing it entirely introduces a new warning on the __ftrace_vbprintk() definition. The format strings still get checked because the underlying literal keeps getting passed into __trace_printk() in the "else" branch, which is not taken but still evaluated for compile-time warnings. Cc: Masami Hiramatsu Cc: Anna Schumaker Cc: Chuck Lever Cc: Simon Horman Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Yury Norov Cc: Randy Dunlap Link: https://patch.msgid.link/20260203164545.3174910-1-arnd@kernel.org Fixes: ec7d8e68ef0e ("sunrpc: add a Kconfig option to redirect dfprintk() o= utput to trace buffer") Acked-by: Jeff Layton Acked-by: Steven Rostedt (Google) Signed-off-by: Arnd Bergmann Acked-by: Andy Shevchenko Signed-off-by: Steven Rostedt (Google) --- include/linux/trace_printk.h | 1 - kernel/trace/trace_printk.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/trace_printk.h b/include/linux/trace_printk.h index bb5874097f24..2670ec7f4262 100644 --- a/include/linux/trace_printk.h +++ b/include/linux/trace_printk.h @@ -107,7 +107,6 @@ do { \ __trace_printk(_THIS_IP_, fmt, ##args); \ } while (0) =20 -extern __printf(2, 3) int __trace_bprintk(unsigned long ip, const char *fmt, ...); =20 extern __printf(2, 3) diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c index 5ea5e0d76f00..3ea17af60169 100644 --- a/kernel/trace/trace_printk.c +++ b/kernel/trace/trace_printk.c @@ -197,6 +197,7 @@ struct notifier_block module_trace_bprintk_format_nb = =3D { .notifier_call =3D module_trace_bprintk_format_notify, }; =20 +__printf(2, 3) int __trace_bprintk(unsigned long ip, const char *fmt, ...) { int ret; --=20 2.51.0