Re: [PATCH bpf-next v1 3/3] selftests/bpf: add test case for userspace and bpf type size mismatch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2022-02-10 at 14:44 -0800, Andrii Nakryiko wrote:
> > +/* declare the int64_t type to actually be 32-bit to ensure the skeleton
> > + * uses actual sizes and doesn't just copy the type name
> > + */
> > +typedef __s32 int64_t;
> > +int64_t intest64 = -1;
> > +int64_t outtest64 = -1;
> 
> This will be so confusing... But when you drop __s32 special handling
> you can just use __s32 directly, right?

Actually, no. We need the type to have the textual representation of a 64-bit
type (int64_t) but a different underlying size. The test is ensuring that the
skeleton is using the underlying type and not the apparent type. 

You need a layer of typedefs to introduce that confusion and intXX_t is ideal
because it's not normally transitively available in .bpf.c programs.

`typedef signed char int64_t;` would also work, if you prefer that.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux