Message ID | 20240107091641.579849-1-bhe@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-18822-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp459797dyq; Sun, 7 Jan 2024 01:17:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCgYK7pTdB+3RgrK9potHwsdGVyVeusUqNYFMhss8SEVUnnYHlfIk6ZCc8W52EfEwOGzgK X-Received: by 2002:a05:6214:262b:b0:680:c83a:3601 with SMTP id gv11-20020a056214262b00b00680c83a3601mr3067687qvb.9.1704619035844; Sun, 07 Jan 2024 01:17:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704619035; cv=none; d=google.com; s=arc-20160816; b=dNTl4opcb1XlSKAARXsTtDBdMyKsEeWZncll5Ey85sqLHvh3w+ppI2aGHw7bnGsSP4 K8sWQoUlmMDjtrjMbCv7eV58WJdRqrb/5OumGOOATw6MvnAqDc9SU93tXOgInWT5u3xb kB2W7/eWDr05Wu+YsWDzggNLL1/oAtjP6Z0Jm5/Gj0TbEHI+mfRLZ0C3+y5rcUtyJgmS 8fE2qMhn+dWWX6rhF9pI/66V9sKadRPV/3ZHoCb5utdCefDFHN1CIJD8sPBc3G17Bvc1 woH3/sy2gMHaKYOzgM1nq4J5F1ODfsawZLYUWvdNo19uc5p12WQ9G9awpu3cJZMxCLan ZEew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=BgudMJ+RWICRf+8Eqkdzm+CoYpLiRVe9izyHKQLDpow=; fh=VlfGtt4OtCZiLeU4PUQ0P/Wjaw0MWJ29LFLxZsW4R2I=; b=N/740FWrPMstgzuTRpjMmXLE1VrgKKGVMHmgxUOvWpPCdLzhuRDtF5Awzh/9qNPLrd tItTyQlsqubZnibCXoCQjC/w1Xai+iSwbPLAk1mD/jU8FHgpK9mkBIx76SgSCe9xq51I L9WEV/lkIRpFX1BDetk4KJf/EYEr1DOk7vBygh6+GvF1Vn+jSjtSf+zAA4qmCtLlYiP0 zBVPpJgzA0nT02FnLqutrWXHN8eQsgz/4zlk9Pp5vc4rc3dIYuR2bQH3va+sBeCXAfVb BawPjQ4BS+A/AE859E6WR8jBdGNXWITaDR4sogvY5oMIjC/3Au4qXMh/nNwHullF2DLn laJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bGQbBQzJ; spf=pass (google.com: domain of linux-kernel+bounces-18822-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18822-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dc35-20020a05620a522300b007831e83f24bsi398517qkb.765.2024.01.07.01.17.15 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 01:17:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18822-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bGQbBQzJ; spf=pass (google.com: domain of linux-kernel+bounces-18822-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18822-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9F9861C20E5D for <ouuuleilei@gmail.com>; Sun, 7 Jan 2024 09:17:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 815E512B8C; Sun, 7 Jan 2024 09:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bGQbBQzJ" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 5181A12B60 for <linux-kernel@vger.kernel.org>; Sun, 7 Jan 2024 09:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704619016; h=from:from: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=BgudMJ+RWICRf+8Eqkdzm+CoYpLiRVe9izyHKQLDpow=; b=bGQbBQzJb/n3TEDdPLLJPSjyXpNWIj2Ax29lKvO9hlzv9z1qLmK04hZ/kZeEh2yy0uS9cE tvtFsH8DgWH0Ny6Z+wyU+cQlFcSpD4X3yW1ON2zythkDlECKBQhCqskra8hh5808zyN+hh wXitGm3yQHE4HE/TgOBhE31qBvF31x8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-mx9G9GVBMsWyf6PcWbO46g-1; Sun, 07 Jan 2024 04:16:47 -0500 X-MC-Unique: mx9G9GVBMsWyf6PcWbO46g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 105BF85A588; Sun, 7 Jan 2024 09:16:47 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24E063C31; Sun, 7 Jan 2024 09:16:44 +0000 (UTC) From: Baoquan He <bhe@redhat.com> To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, pmladek@suse.com, Baoquan He <bhe@redhat.com> Subject: [PATCH] panic: suppress gnu_printf warning Date: Sun, 7 Jan 2024 17:16:41 +0800 Message-ID: <20240107091641.579849-1-bhe@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787422610375811083 X-GMAIL-MSGID: 1787422610375811083 |
Series |
panic: suppress gnu_printf warning
|
|
Commit Message
Baoquan He
Jan. 7, 2024, 9:16 a.m. UTC
with GCC 13.2.1 and W=1, there's compiling warning like this:
kernel/panic.c: In function ‘__warn’:
kernel/panic.c:676:17: warning: function ‘__warn’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
676 | vprintk(args->fmt, args->args);
| ^~~~~~~
The normal __printf(x,y) adding can't fix it. So add workaround which
disables -Wsuggest-attribute=format to mute it.
Signed-off-by: Baoquan He <bhe@redhat.com>
---
kernel/panic.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
On Sun, 7 Jan 2024 17:16:41 +0800 Baoquan He <bhe@redhat.com> wrote: > with GCC 13.2.1 and W=1, there's compiling warning like this: > > kernel/panic.c: In function ‘__warn’: > kernel/panic.c:676:17: warning: function ‘__warn’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] > 676 | vprintk(args->fmt, args->args); > | ^~~~~~~ > > The normal __printf(x,y) adding can't fix it. So add workaround which > disables -Wsuggest-attribute=format to mute it. > > ... > > --- a/kernel/panic.c > +++ b/kernel/panic.c > @@ -666,8 +666,13 @@ void __warn(const char *file, int line, void *caller, unsigned taint, > pr_warn("WARNING: CPU: %d PID: %d at %pS\n", > raw_smp_processor_id(), current->pid, caller); > > +#pragma GCC diagnostic push > +#ifndef __clang__ > +#pragma GCC diagnostic ignored "-Wsuggest-attribute=format" > +#endif > if (args) > vprintk(args->fmt, args->args); > +#pragma GCC diagnostic pop > > print_modules(); __warn() clearly isn't such a candidate. I'm suspecting that gcc's implementation of this warning is pretty crude. Is it a new thing in gcc-13.2? A bit of context for gcc@gcc.gnu.org: struct warn_args { const char *fmt; va_list args; }; ... void __warn(const char *file, int line, void *caller, unsigned taint, struct pt_regs *regs, struct warn_args *args) { disable_trace_on_warning(); if (file) pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n", raw_smp_processor_id(), current->pid, file, line, caller); else pr_warn("WARNING: CPU: %d PID: %d at %pS\n", raw_smp_processor_id(), current->pid, caller); if (args) vprintk(args->fmt, args->args); print_modules(); if (regs) show_regs(regs); check_panic_on_warn("kernel"); if (!regs) dump_stack(); print_irqtrace_events(current); print_oops_end_marker(); trace_error_report_end(ERROR_DETECTOR_WARN, (unsigned long)caller); /* Just a warning, don't kill lockdep. */ add_taint(taint, LOCKDEP_STILL_OK); }
On 01/07/24 at 10:21am, Andrew Morton wrote: > On Sun, 7 Jan 2024 17:16:41 +0800 Baoquan He <bhe@redhat.com> wrote: > > > with GCC 13.2.1 and W=1, there's compiling warning like this: > > > > kernel/panic.c: In function ‘__warn’: > > kernel/panic.c:676:17: warning: function ‘__warn’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format] > > 676 | vprintk(args->fmt, args->args); > > | ^~~~~~~ > > > > The normal __printf(x,y) adding can't fix it. So add workaround which > > disables -Wsuggest-attribute=format to mute it. > > > > ... > > > > --- a/kernel/panic.c > > +++ b/kernel/panic.c > > @@ -666,8 +666,13 @@ void __warn(const char *file, int line, void *caller, unsigned taint, > > pr_warn("WARNING: CPU: %d PID: %d at %pS\n", > > raw_smp_processor_id(), current->pid, caller); > > > > +#pragma GCC diagnostic push > > +#ifndef __clang__ > > +#pragma GCC diagnostic ignored "-Wsuggest-attribute=format" > > +#endif > > if (args) > > vprintk(args->fmt, args->args); > > +#pragma GCC diagnostic pop > > > > print_modules(); > > __warn() clearly isn't such a candidate. I'm suspecting that gcc's > implementation of this warning is pretty crude. Is it a new thing in > gcc-13.2? Yeah, this isn't like other warnings in kernel. The compiler seems too smart by look into the parameter 'args' of 'struct warn_args*'. > > A bit of context for gcc@gcc.gnu.org: > > struct warn_args { > const char *fmt; > va_list args; > }; > > ... > > void __warn(const char *file, int line, void *caller, unsigned taint, > struct pt_regs *regs, struct warn_args *args) > { > disable_trace_on_warning(); > > if (file) > pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS\n", > raw_smp_processor_id(), current->pid, file, line, > caller); > else > pr_warn("WARNING: CPU: %d PID: %d at %pS\n", > raw_smp_processor_id(), current->pid, caller); > > if (args) > vprintk(args->fmt, args->args); > > print_modules(); > > if (regs) > show_regs(regs); > > check_panic_on_warn("kernel"); > > if (!regs) > dump_stack(); > > print_irqtrace_events(current); > > print_oops_end_marker(); > trace_error_report_end(ERROR_DETECTOR_WARN, (unsigned long)caller); > > /* Just a warning, don't kill lockdep. */ > add_taint(taint, LOCKDEP_STILL_OK); > } >
diff --git a/kernel/panic.c b/kernel/panic.c index 2807639aab51..d49b68184c56 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -666,8 +666,13 @@ void __warn(const char *file, int line, void *caller, unsigned taint, pr_warn("WARNING: CPU: %d PID: %d at %pS\n", raw_smp_processor_id(), current->pid, caller); +#pragma GCC diagnostic push +#ifndef __clang__ +#pragma GCC diagnostic ignored "-Wsuggest-attribute=format" +#endif if (args) vprintk(args->fmt, args->args); +#pragma GCC diagnostic pop print_modules();