From: Jiri Olsa <jolsa@redhat.com>
To: Andrii Nakryiko <andriin@fb.com>
Cc: Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
Yonghong Song <yhs@fb.com>, Martin Lau <kafai@fb.com>
Subject: Re: [PATCH 0/7] libbpf: Fix cast away const qualifiers in btf.h
Date: Sat, 7 Sep 2019 08:54:13 +0200 [thread overview]
Message-ID: <20190907065413.GA31822@krava> (raw)
In-Reply-To: <62e760de-e746-c512-350a-c2188a2bb3ed@fb.com>
On Fri, Sep 06, 2019 at 09:09:17AM +0000, Andrii Nakryiko wrote:
> On 9/6/19 8:31 AM, Jiri Olsa wrote:
> > hi,
> > when including btf.h in bpftrace, I'm getting -Wcast-qual warnings like:
> >
> > bpf/btf.h: In function ‘btf_var_secinfo* btf_var_secinfos(const btf_type*)’:
> > bpf/btf.h:302:41: warning: cast from type ‘const btf_type*’ to type
> > ‘btf_var_secinfo*’ casts away qualifiers [-Wcast-qual]
> > 302 | return (struct btf_var_secinfo *)(t + 1);
> > | ^
> >
> > I changed the btf.h header to comply with -Wcast-qual checks
> > and used const cast away casting in libbpf objects, where it's
>
> Hey Jiri,
>
> We made all those helper funcs return non-const structs intentionally to
> improve their usability and avoid all those casts that you added back.
>
> Also, those helpers are now part of public API, so we can't just change
> them to const, as it can break existing users easily.
>
> If there is a need to run with -Wcast-qual, we should probably disable
> those checks where appropriate in libbpf code.
>
> So this will be a NACK from me, sorry.
ok, I'll disable disable it in bpftrace code then
thanks,
jirka
>
> > all related to deduplication code, so I believe loosing const
> > is fine there.
> >
> > thanks,
> > jirka
> >
> >
> > ---
> > Jiri Olsa (7):
> > libbpf: Use const cast for btf_int_* functions
> > libbpf: Return const btf_array from btf_array inline function
> > libbpf: Return const btf_enum from btf_enum inline function
> > libbpf: Return const btf_member from btf_members inline function
> > libbpf: Return const btf_param from btf_params inline function
> > libbpf: Return const btf_var from btf_var inline function
> > libbpf: Return const struct btf_var_secinfo from btf_var_secinfos inline function
> >
> > tools/lib/bpf/btf.c | 21 +++++++++++----------
> > tools/lib/bpf/btf.h | 30 +++++++++++++++---------------
> > tools/lib/bpf/libbpf.c | 2 +-
> > 3 files changed, 27 insertions(+), 26 deletions(-)
> >
>
prev parent reply other threads:[~2019-09-07 6:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 7:31 [PATCH 0/7] libbpf: Fix cast away const qualifiers in btf.h Jiri Olsa
2019-09-06 7:31 ` [PATCH 1/7] libbpf: Use const cast for btf_int_* functions Jiri Olsa
2019-09-06 7:31 ` [PATCH 2/7] libbpf: Return const btf_array from btf_array inline function Jiri Olsa
2019-09-06 7:31 ` [PATCH 3/7] libbpf: Return const btf_enum from btf_enum " Jiri Olsa
2019-09-06 7:31 ` [PATCH 4/7] libbpf: Return const btf_member from btf_members " Jiri Olsa
2019-09-06 7:31 ` [PATCH 5/7] libbpf: Return const btf_param from btf_params " Jiri Olsa
2019-09-06 7:31 ` [PATCH 6/7] libbpf: Return const btf_var from btf_var " Jiri Olsa
2019-09-06 7:31 ` [PATCH 7/7] libbpf: Return const struct btf_var_secinfo from btf_var_secinfos " Jiri Olsa
2019-09-06 9:09 ` [PATCH 0/7] libbpf: Fix cast away const qualifiers in btf.h Andrii Nakryiko
2019-09-06 17:03 ` Alexei Starovoitov
2019-09-07 6:54 ` Jiri Olsa [this message]
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=20190907065413.GA31822@krava \
--to=jolsa@redhat.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jolsa@kernel.org \
--cc=kafai@fb.com \
--cc=netdev@vger.kernel.org \
--cc=yhs@fb.com \
/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).