Re: [PATCH 09/12] enum: only warn (once) when mixing bitwiseness

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

 



On Fri, Sep 7, 2018 at 5:01 PM Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
>
> In the kernel, some enums are defined with such bitwise types
> as initializers; the goal being to have slightly more strict enums.
> While the semantic of such enums is not very clear, using a mix
> of bitwise and not-bitwise initializers completely defeats the
> desired stricter typing.

Hmm.

We consider 0 to be special, in that it matches all bitwise types.

So

    typedef long long __bitwise bits;

    enum a {
        one = 0,
        two = (__force bits) 1,
    };

feels like it should work (and result in everything being of type
"bits"), but looking at this patch I suspect it results in a warning.

Note! Just reading the patch, not actually testing it.

              Linus



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux