[Xcb] [PATCH] c_client.py: Always initialize xcb_align_to

Daniel Martin consume.noise at gmail.com
Mon Aug 12 14:46:56 PDT 2013


On Sun, Aug 11, 2013 at 04:03:31PM +0200, Uli Schlachter wrote:
> On 09.01.2013 12:52, Daniel Martin wrote:
> > to get rid of:
> >     warning: 'xcb_align_to' may be used uninitialized in this function
> 
> Uhm. I don't get such a warning here. Could you add some information on where
> that warning comes from (source code location, compiler version) and perhaps
> also on why it happens? (=Why is this a correct fix instead of just hiding the
> problem?)

Just was able to reproduce it. It shows up in serialize functions, when
changing the optimization from -O2 to -O0. For example:

xkb.c: In function 'xcb_xkb_get_map_map_serialize':
xkb.c:6249:50: warning: 'xcb_align_to' may be used uninitialized in this function [-Wmaybe-uninitialized]
         xcb_pad = -xcb_block_len & (xcb_align_to - 1);
                                                  ^

Here's the code:

int
xcb_xkb_get_map_map_serialize (void                        **_buffer  /**< */,
                               8< more parameters 8<
                               const xcb_xkb_get_map_map_t  *_aux  /**< */)
{
    char *xcb_out = *_buffer;
    unsigned int xcb_buffer_len = 0;
    unsigned int xcb_align_to;

    unsigned int xcb_pad = 0;
    char xcb_pad0[3] = {0, 0, 0};
    struct iovec xcb_parts[19];
    unsigned int xcb_parts_idx = 0;
    unsigned int xcb_block_len = 0;
    unsigned int i;
    char *xcb_tmp;

    if(present & XCB_XKB_MAP_PART_KEY_TYPES) {
        /* insert padding */
        xcb_pad = -xcb_block_len & (xcb_align_to - 1);
        ...

Why doesn't it show up with -O2?


More information about the Xcb mailing list