From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH iproute2] iproute: make clang happy Date: Mon, 20 Aug 2018 17:52:32 -0700 Message-ID: <20180820175232.6a0877fe@xeon-e3> References: <20180820214215.218127-1-mahesh@bandewar.net> <20180820155223.0569b849@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Mahesh Bandewar , netdev To: "Mahesh Bandewar (=?UTF-8?B?4KSu4KS54KWH4KS2IOCkrOCkguCkoeClh+CktQ==?= =?UTF-8?B?4KS+4KSw?=)" Return-path: Received: from mail-pl0-f65.google.com ([209.85.160.65]:32931 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725736AbeHUEK1 (ORCPT ); Tue, 21 Aug 2018 00:10:27 -0400 Received: by mail-pl0-f65.google.com with SMTP id b90-v6so7948609plb.0 for ; Mon, 20 Aug 2018 17:52:34 -0700 (PDT) In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 20 Aug 2018 16:44:28 -0700 Mahesh Bandewar (=E0=A4=AE=E0=A4=B9=E0=A5=87=E0=A4=B6 =E0=A4=AC=E0=A4=82=E0= =A4=A1=E0=A5=87=E0=A4=B5=E0=A4=BE=E0=A4=B0) wrote: > On Mon, Aug 20, 2018 at 4:38 PM, Mahesh Bandewar (=E0=A4=AE=E0=A4=B9=E0= =A5=87=E0=A4=B6 =E0=A4=AC=E0=A4=82=E0=A4=A1=E0=A5=87=E0=A4=B5=E0=A4=BE=E0= =A4=B0) > wrote: > > On Mon, Aug 20, 2018 at 3:52 PM, Stephen Hemminger > > wrote: =20 > >> On Mon, 20 Aug 2018 14:42:15 -0700 > >> Mahesh Bandewar wrote: > >> =20 > >>> diff --git a/tc/m_ematch.c b/tc/m_ematch.c > >>> index ace4b3dd738b..a524b520b276 100644 > >>> --- a/tc/m_ematch.c > >>> +++ b/tc/m_ematch.c > >>> @@ -277,6 +277,7 @@ static int flatten_tree(struct ematch *head, stru= ct ematch *tree) > >>> return count; > >>> } > >>> > >>> +__attribute__((format(printf, 5, 6))) > >>> int em_parse_error(int err, struct bstr *args, struct bstr *carg, > >>> struct ematch_util *e, char *fmt, ...) =20 > >> > >> I think the printf attribute needs to go on the function prototype > >> here: > >> tc/m_ematch.h:extern int em_parse_error(int err, struct bstr *args, st= ruct bstr *carg, > >> =20 > > The attributes are attached to the definitions only and not prototype > > declarations. Please see the definition/declaration for jsonw_printf() > > in the same patch. =20 > I take that back. Seems like it's fine either way. The reason to put the attributes in the .h file is that then the compiler can test for misuse in other files. For example if em_parse_error had a bad format in em_u32.c, then the warning would not happen unless the attribute was on the function prototype.