From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by sourceware.org (Postfix) with ESMTPS id 001A23858D35 for ; Sun, 7 Jan 2024 18:21:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 001A23858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux-foundation.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 001A23858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2604:1380:4641:c500::1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704651668; cv=none; b=o5Vm17E60N6Ere+kYnx8RiSkwI4iZ1rtxoRpxTVad/zvblr5jkqfTzYTeTX4gWbMfQ+kV2GGpT0QPuV7cofPaHxEFInzoeuj6YnmhbLAxm/kWmLTwYVK2W0LxvYmm1ZFzC/Ymxig4euq0I8KfDmvSq18xLoum6zS4Ex5YuSFBZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704651668; c=relaxed/simple; bh=sZPBGcFilnJgnQg/CYPYjTdMMjgjwjmQd4ivbtePeo8=; h=DKIM-Signature:Date:From:To:Subject:Message-Id:Mime-Version; b=Cn6coHVIsmK8RrMqu8JobXPMDwfwUGFPvxMPkbeJS7ZDBtveFWhCACTJJxa888yBG4OJECRYrjJGoPuDCG71rndRcYtHd7f/TgLXN3qNJ39coPTeKySDE+vCrDPoW4SiXaZSMDssTiguvdgUFNukInitsHUG3pe5i6l1xNklOMM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7E51060BDC; Sun, 7 Jan 2024 18:21:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF2FDC433C8; Sun, 7 Jan 2024 18:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1704651664; bh=sZPBGcFilnJgnQg/CYPYjTdMMjgjwjmQd4ivbtePeo8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dwENUuliYF0nyFc92wP0odwzDw6aRV3mytuf+PZjrGFOYpUd7Ezxyeyxi0wk2Egpx osKfrTzGM/WcEL+7B5syCr0rK7pRVC4IbMyNWOH8JVJqqPxICMNKtKrZpyoCg3FaRc 7NwZy+Vj0O8vpxN6eARxoDrgbjPmTUSe/5FtLDIk= Date: Sun, 7 Jan 2024 10:21:03 -0800 From: Andrew Morton To: Baoquan He Cc: linux-kernel@vger.kernel.org, pmladek@suse.com, gcc@gcc.gnu.org Subject: Re: [PATCH] panic: suppress gnu_printf warning Message-Id: <20240107102103.3c0ba0cfa4df37df4b59090e@linux-foundation.org> In-Reply-To: <20240107091641.579849-1-bhe@redhat.com> References: <20240107091641.579849-1-bhe@redhat.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, 7 Jan 2024 17:16:41 +0800 Baoquan He 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); }