[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190807193011.g2zuaapc2uvvr4h6@ast-mbp>
Date: Wed, 7 Aug 2019 12:30:12 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Andrii Nakryiko <andriin@...com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, ast@...com,
daniel@...earbox.net, yhs@...com, andrii.nakryiko@...il.com,
kernel-team@...com
Subject: Re: [PATCH v4 bpf-next 02/14] libbpf: convert libbpf code to use new
btf helpers
On Tue, Aug 06, 2019 at 10:37:54PM -0700, Andrii Nakryiko wrote:
> Simplify code by relying on newly added BTF helper functions.
>
> Signed-off-by: Andrii Nakryiko <andriin@...com>
..
>
> - for (i = 0, vsi = (struct btf_var_secinfo *)(t + 1);
> - i < vars; i++, vsi++) {
> + for (i = 0, vsi = (void *)btf_var_secinfos(t); i < vars; i++, vsi++) {
> + struct btf_member *m = (void *)btf_members(t);
...
> case BTF_KIND_ENUM: {
> - struct btf_enum *m = (struct btf_enum *)(t + 1);
> - __u16 vlen = BTF_INFO_VLEN(t->info);
> + struct btf_enum *m = (void *)btf_enum(t);
> + __u16 vlen = btf_vlen(t);
...
> case BTF_KIND_FUNC_PROTO: {
> - struct btf_param *m = (struct btf_param *)(t + 1);
> - __u16 vlen = BTF_INFO_VLEN(t->info);
> + struct btf_param *m = (void *)btf_params(t);
> + __u16 vlen = btf_vlen(t);
So all of these 'void *' type hacks are only to drop const-ness ?
May be the helpers shouldn't be taking const then?
Powered by blists - more mailing lists