lkml.org 
[lkml]   [2022]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 bpf-next] libbpf: Add bpf_obj_get_opts()
On Wed, Jul 27, 2022 at 04:02:43PM -0700, Andrii Nakryiko wrote:

Applied both of these in v3, which I'll send out in a moment. Thanks for
the feedback!

> > int bpf_obj_get(const char *pathname)
> > +{
> > + LIBBPF_OPTS(bpf_obj_get_opts, opts);
>
> if you were doing it this way, here should be an empty line. But
> really you can/should just pass NULL instead of opts in this case.

> > +struct bpf_obj_get_opts {
> > + size_t sz; /* size of this struct for forward/backward compatibility */
> > +
> > + __u32 file_flags;
>
> please add size_t :0; to avoid non-zero-initialized padding (we do it
> in a lot of other opts structs)
>

TIL about this trick. Very clever.

\
 
 \ /
  Last update: 2022-07-29 22:20    [W:0.193 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site