[Xcb] [PATCH] c_client.py: Prefer bit shifts over values in enum

Daniel Martin consume.noise at gmail.com
Tue Jul 29 13:26:11 PDT 2014


Attention, thread necromancy ...

On Wed, Jul 03, 2013 at 07:26:48PM -0400, Peter Harris wrote:
> On 2013-06-07 02:21, Daniel Martin wrote:
> > On Fri, Jun 07, 2013 at 12:00:39AM +0200, Daniel Martin wrote:
> >> When generating enum structures, prefer bit shifts over values. And
> >> align the equal signs.
> 
> That looks like a reasonable clean-up.
> 
> > Forgotten to mention: With this patch, we ge rid of a compiler warning
> > as well:
> >     xkb.h:118:40: warning: ISO C restricts enumerator values to range \
> >        of 'int' [-Wpedantic]
> >          XCB_XKB_CONTROL_CONTROLS_ENABLED = 2147483648
> 
> That's a bit scary, actually, as the bit-shift replacement will also
> generate a value outside the range of int, and now we're relying on
> implementation defined behaviour in addition to a gcc extension (1 <<
> 31) is implementation defined, since it's outside the range of int. (1u
> << 31u) is standard C (given a 32-bit int, which I think everything we
> support has)).

Just applied my rusty patch and added -pedantic:

    xkb.h:118:40: warning: ISO C restricts enumerator values to range of
        'int' [-Wpedantic]
            XCB_XKB_CONTROL_CONTROLS_ENABLED = (1u << 31u)

If I change the value to (1 << 31u) or even (1 << 31) the warning
doesn't trigger.

Any idea or wish how I should change the patch, how the resulting value
should like?


Cheers,
    Daniel


More information about the Xcb mailing list