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

Peter Harris pharris at opentext.com
Wed Jul 3 16:26:48 PDT 2013


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)).

Peter Harris
-- 
               Open Text Connectivity Solutions Group
Peter Harris                    http://connectivity.opentext.com/
Research and Development        Phone: +1 905 762 6001
pharris at opentext.com            Toll Free: 1 877 359 4866


More information about the Xcb mailing list