Re: [PATCH v3 bpf-next 1/3] bpf: switch BPF UAPI #define constants used from BPF program side to enums

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

 



On Tue, Jun 2, 2020 at 4:21 PM Michael Forney <mforney@xxxxxxxxxxx> wrote:
>
> On 2020-06-02, Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote:
> > the enum definition of BPF_F_CTXLEN_MASK is certainly within standard.
> > I don't think kernel should adjust its headers because some compiler
> > is failing to understand C standard.
>
> This is not true. See C11 6.7.2.2p2: "The expression that defines the
> value of an enumeration constant shall be an integer constant
> expression that has a value representable as an int."
>
> You can also see this with gcc if you turn on -Wpedantic and include
> it in a way such that warnings are not silenced:
>
> $ gcc -Wpedantic -x c -c -o /dev/null /usr/include/linux/bpf.h

ISO C forbids zero-size arrays, unnamed struct/union, gcc extensions,
empty unions, etc
So ?

warning: ISO C forbids zero-size array ‘args’ [-Wpedantic]
 4095 |  __u64 args[0];
 warning: ISO C90 doesn’t support unnamed structs/unions [-Wpedantic]
 3795 |  __bpf_md_ptr(void *, data_end);

#define BPF_F_CTXLEN_MASK BPF_F_CTXLEN_MASK
will only work as workaround for _your_ compiler.
We are not gonna add hacks like this for every compiler.




[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