From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3735978F2B for ; Tue, 16 Dec 2025 09:35:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765877760; cv=none; b=sdEqG/LKOZcZ6pyaDCfrZrED6ldJDZligJ1cMpeN9GsnhVvuqViImEX9uUkgeNSK8xt3o+CWeJtcVSxKtOo2/Z6KP2MNMPtkHj9oaAqvJ8rU29kQxIkxHXGqKoOub+gpaz7gL/00+Yp0VIfpLfMwsV01AhlxqXk6M30oDO8Rq2A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765877760; c=relaxed/simple; bh=gU4LR+WoS9SR2IP+B2LFOUyLWxDuWNbgftxL8deLdsk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Xlz06OC1/ldJHEUGiHEyflemB1UWrWZMgjNUt+vc7bDhJYjjTDIbSqoojDyJQYe249P5GFKaFqes7aZVFSnLdawAjmbo4rzftp5M7oJsU/Dp2gP6uHvqQ/V87thditunEdb/nsoif9BQ0dPF+FnwMvdcQsC7juJ7hZoywuokTNc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=huaB48rK; arc=none smtp.client-ip=209.85.218.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jackmanb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="huaB48rK" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-b7fe37056e1so130062766b.2 for ; Tue, 16 Dec 2025 01:35:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765877757; x=1766482557; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=6HavHDl091OihXXz8CeXGOusvlz/IM2nYpeSxNI5Yjo=; b=huaB48rKh9ijHVjlYsxhzNrqAz73ZAe2R5dcKo3d62emzUzogaq94phhocUJ46t47F f3mMmFkb5NaW/2PAo7tDIwy9h7ZQFlWvJ8WU5Nl7tlAeQC3rTdOSGiR9WGcoSMlPGIVG QRdW5sugadqL4Q2pxtOrIYAd4eIbHrAwsZVsgensG/mQPthAGC9103Qgp7aw+NQK4Gnn dt/DZV0LoeUlfgT1wJgjZUTCJL14aCJNwn7UPNGMQXtF6I7/6Iw48Zbkew/0D7clOH3W u9PCVL9crQU7XDDQM1wyPQ4YnLOo7LaT931EN1En05Vs+yT6OBGbVP+vvoHMqx51Dwml wjlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765877757; x=1766482557; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=6HavHDl091OihXXz8CeXGOusvlz/IM2nYpeSxNI5Yjo=; b=j/HcbTFjCWskzIr3ef1i+xzQNirS9e19dbekrlMR+TYjUfHk/okziDAmUqhOJP+hOH GJS0IKwMbbqJ3SgBfVo5bihl+w2/ROQJKew9GaMFJfAkxTuh69cSrGlr9rbhOZ+G35QA U1z+s7gWa/BPPdzXyWuMAOukjSaKZVImpDR0+66GHHHTHEAux1vU4oOFdmsU8vWxaxm7 DlW/E3/YvIvtkP8KN1kbQBe/+0rEYA9Kmbi1AIMj4tHYf7WiTLWHLXcMHAHmeeOyTJKz hte8JCrgDooFXgPtTWqIQ2VUi/ktuJXZe4gtJpPEGRf/ZixQ/rKhfljqbuEYwzoOtgUT Pfvg== X-Forwarded-Encrypted: i=1; AJvYcCXW0IXyXAgy7//gC5TuuoxyQynVcjc1JJm8CkvQ9IRdGazL2fd/IO19DlN7et3XFHWkWD3JAzMVqIZpbFQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0Pl/BaQgxrnVBRup+Voe6ELeaDj6A0kaTzoK6tTmTCznEzHO7 1WOWuI/EDfDn3T2v6bc/ZIux/WGlpS63tNmX5sDCPCphn1HRjcCcKq2dVXFgvO+qjYQQIcqAGCb tQsmIoYcGJSN5Mg== X-Google-Smtp-Source: AGHT+IFRsdtua6bHVoH+2boEjUriNhn9KHs55iyx3iLnTMORk7REiYbvHEl4XFvgL3uAVyK3rbOEtm1U8TELSQ== X-Received: from ejcus9.prod.google.com ([2002:a17:907:cd09:b0:b77:1580:1051]) (user=jackmanb job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:7254:b0:b76:f5d0:5df4 with SMTP id a640c23a62f3a-b7d23ad6678mr1357971866b.31.1765877757514; Tue, 16 Dec 2025 01:35:57 -0800 (PST) Date: Tue, 16 Dec 2025 09:35:56 +0000 In-Reply-To: <20251208141618.2805983-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251208141618.2805983-1-andriy.shevchenko@linux.intel.com> X-Mailer: aerc 0.21.0 Message-ID: Subject: Re: [PATCH v1 1/1] bug: Mark __warn_printf() with __printf() attribute From: Brendan Jackman To: Andy Shevchenko , Peter Zijlstra , Cc: Andrew Morton Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon Dec 8, 2025 at 2:16 PM UTC, Andy Shevchenko wrote: > __warn_printf() is using printf() type of format, and compiler > is not happy about them as is: > > lib/bug.c:187:25: error: function =E2=80=98__warn_printf=E2=80=99 might b= e a candidate for =E2=80=98gnu_printf=E2=80=99 format attribute [-Werror=3D= suggest-attribute=3Dformat] > 187 | vprintk(fmt, *args); > | ^~~~~~~ > > Fix the compilation errors by adding __printf() attribute. > > Fixes: 5c47b7f3d1a9 ("bug: Add BUG_FORMAT_ARGS infrastructure") > Signed-off-by: Andy Shevchenko > --- > lib/bug.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/bug.c b/lib/bug.c > index edd9041f89f3..d7db57280ab7 100644 > --- a/lib/bug.c > +++ b/lib/bug.c > @@ -173,7 +173,7 @@ struct bug_entry *find_bug(unsigned long bugaddr) > return module_find_bug(bugaddr); > } > =20 > -static void __warn_printf(const char *fmt, struct pt_regs *regs) > +static __printf(1, 0) void __warn_printf(const char *fmt, struct pt_regs= *regs) > { > if (!fmt) > return; In [0] I fixed this error by disabling the warning locally. My rationale (which I didn't write in the patch, sorry) was that the pt_regs argument doesn't correspond to any specifier in the format string so this was a false positive.=20 However, I didn't realise you can specify 0 for the final arg - the GCC docs[1] say: > For functions where the arguments are not available to be checked > (such as vprintf), specify the third parameter as zero. In this case > the compiler only checks the format string for consistency.=20 So I think what what we get here is a check that the format string isn't garbage, without any expectation that theres a %p or whatever for the pt_regs. Maybe it's worth noting this down in the commit message? Other than that, thanks, this seems superior to my patch: Reviewed-by: Brendan Jackman [0] https://lore.kernel.org/all/20251207-warn-printf-gcc-v1-1-b597d612b94b@= google.com/ [1] https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Attributes.html