From: Stephen Hemminger <stephen@networkplumber.org>
To: "Mahesh Bandewar (महेश बंडेवार)" <maheshb@google.com>
Cc: Mahesh Bandewar <mahesh@bandewar.net>, netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH iproute2] iproute: make clang happy
Date: Mon, 20 Aug 2018 17:52:32 -0700 [thread overview]
Message-ID: <20180820175232.6a0877fe@xeon-e3> (raw)
In-Reply-To: <CAF2d9jh3xq_F799Dn0=R0XK7NAkrQxmREg++sT4e3MpVLsnPpw@mail.gmail.com>
On Mon, 20 Aug 2018 16:44:28 -0700
Mahesh Bandewar (महेश बंडेवार) <maheshb@google.com> wrote:
> On Mon, Aug 20, 2018 at 4:38 PM, Mahesh Bandewar (महेश बंडेवार)
> <maheshb@google.com> wrote:
> > On Mon, Aug 20, 2018 at 3:52 PM, Stephen Hemminger
> > <stephen@networkplumber.org> wrote:
> >> On Mon, 20 Aug 2018 14:42:15 -0700
> >> Mahesh Bandewar <mahesh@bandewar.net> wrote:
> >>
> >>> 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, struct 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, ...)
> >>
> >> 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, struct bstr *carg,
> >>
> > The attributes are attached to the definitions only and not prototype
> > declarations. Please see the definition/declaration for jsonw_printf()
> > in the same patch.
> 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.
next prev parent reply other threads:[~2018-08-21 4:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-20 21:42 [PATCH iproute2] iproute: make clang happy Mahesh Bandewar
2018-08-20 22:50 ` Stephen Hemminger
2018-08-21 0:32 ` Mahesh Bandewar (महेश बंडेवार)
2018-08-20 22:52 ` Stephen Hemminger
2018-08-20 23:38 ` Mahesh Bandewar (महेश बंडेवार)
2018-08-20 23:44 ` Mahesh Bandewar (महेश बंडेवार)
2018-08-21 0:33 ` Mahesh Bandewar (महेश बंडेवार)
2018-08-21 0:52 ` Stephen Hemminger [this message]
2018-08-21 16:19 ` Mahesh Bandewar (महेश बंडेवार)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180820175232.6a0877fe@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=mahesh@bandewar.net \
--cc=maheshb@google.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).