From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 784D3C433EF for ; Wed, 2 Mar 2022 11:52:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08CF28D0002; Wed, 2 Mar 2022 06:52:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 03D838D0001; Wed, 2 Mar 2022 06:52:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6D948D0002; Wed, 2 Mar 2022 06:52:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id D9ADC8D0001 for ; Wed, 2 Mar 2022 06:52:57 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 972F0121D80 for ; Wed, 2 Mar 2022 11:52:57 +0000 (UTC) X-FDA: 79199284794.12.04B4E79 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf30.hostedemail.com (Postfix) with ESMTP id F14A78000C for ; Wed, 2 Mar 2022 11:52:56 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id AD2281F37E; Wed, 2 Mar 2022 11:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1646221975; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=17Yx87zcUkbxgqjZC6j2RKiiBVRCwqSfkoMpziNTDNM=; b=nXIttdMYoc1ALis0aYUH0cDJw8pOnFSjZ7x9GMK6AF3pTLTf9rb7mXrDkRqGV/gCepIuGd Dqs4jXuWKFa1ihM5BrGLxKiwgD4hUchct6XQuu26F7UGjR5cxrUXHJnhaZgN4y1YQ5O0O7 8fy/2eoT9zP6RrnbySW5W5Yt0Fv7rYM= Received: from suse.cz (unknown [10.100.224.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 18019A3B83; Wed, 2 Mar 2022 11:52:55 +0000 (UTC) Date: Wed, 2 Mar 2022 12:52:54 +0100 From: Petr Mladek To: John Ogness Cc: Matthew Wilcox , Andrew Morton , kernel test robot , Maninder Singh , kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, Johannes Weiner , Vaneet Narang , Linux Memory Management List , Sergey Senozhatsky , Steven Rostedt Subject: Re: [hnaz-mm:master 272/379] lib/vsprintf.c:991:13: warning: variable 'modbuildid' set but not used Message-ID: References: <202203012040.uFWGm3My-lkp@intel.com> <20220301102448.ff9bf910213d705842a2dd45@linux-foundation.org> <8735k0isum.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8735k0isum.fsf@jogness.linutronix.de> X-Rspamd-Queue-Id: F14A78000C X-Stat-Signature: pgc8f36kbxs6twi3p3mt78dnshia6nxt X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=nXIttdMY; spf=pass (imf30.hostedemail.com: domain of pmladek@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=pmladek@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam07 X-HE-Tag: 1646221976-648590 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed 2022-03-02 10:58:49, John Ogness wrote: > On 2022-03-01, Matthew Wilcox wrote: > >> > lib/vsprintf.c: In function 'va_format': > >> > lib/vsprintf.c:1759:9: warning: function 'va_format' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format] > >> > 1759 | buf += vsnprintf(buf, end > buf ? end - buf : 0, va_fmt->fmt, va); > >> > | ^~~ > >> > >> I wonder what this means. > > > > It means the compiler thinks we might want to add: > > > > __attribute__((format(gnu_printf, x, y))) to the function declaration so it > > can type-check the arguments. > > > > 'format (ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)' > > The 'format' attribute specifies that a function takes 'printf', > > 'scanf', 'strftime' or 'strfmon' style arguments that should be > > type-checked against a format string. For example, the > > declaration: > > > > extern int > > my_printf (void *my_object, const char *my_format, ...) > > __attribute__ ((format (printf, 2, 3))); > > > > causes the compiler to check the arguments in calls to 'my_printf' > > for consistency with the 'printf' style format string argument > > 'my_format'. > > > > > > I haven't looked into this at all and have no idea if we should. > > AFAICT it is not possible to use the gnu_printf format attribute for > this because the va_list to check is a field within the passed in struct > pointer @va_fmt. My understanding is that it can be handled by passing '0' as the FIRST-TO-CHECK parameter: format (archetype, string-index, first-to-check) The format attribute specifies that a function takes printf, scanf, strftime or strfmon style arguments that should be type-checked against a format string. For example, the declaration: [...] "For functions where the arguments are not available to be checked (such as vprintf), specify the third parameter as zero." , cut&pasted from https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes Well, this particular function va_format() is never used with open-coded @arg parameter. It always just passes @arg from the caller. So that the check is not important. Best Regards, Petr