[Xcb] XCB parsing and valueparam

Barton C Massey bart at cs.pdx.edu
Fri Aug 29 02:18:44 PDT 2008


In message <20080829083555.GE3793 at abydos.adm.naquadah.org> you wrote:
> At 1219993454 time_t, Barton C Massey wrote:
> > The specific problem here is that there is not supposed to
> > be any padding on the end of the ConfigureWindow request
> > (see the protocol spec p. 125).  The LISTofVALUE on the end
> > should have a 2-byte pad between the bitmask and the (zero
> > or more) values, but that's presumably taken care of by
> > valueparam.  The current code generator is doing the right
> > thing here. :-)
> 
> I don't think so. The C struct generated by the code is:
> 
> typedef struct xcb_configure_window_request_t {
>     uint8_t      major_opcode; /**<  */
>     uint8_t      pad0; /**<  */
>     uint16_t     length; /**<  */
>     xcb_window_t window; /**<  */
>     uint16_t     value_mask; /**<  */
> } xcb_configure_window_request_t;
> 
> and does not include the value_param (which is ok since it's only used
> in the function xcb_configure_window() later:
> 
> xcb_void_cookie_t
> xcb_configure_window (xcb_connection_t *c  /**< */,
>                       xcb_window_t      window  /**< */,
>                       uint16_t          value_mask  /**< */,
>                       const uint32_t   *value_list  /**< */);
> 
> which fill a xcb_configure_window_request_t automagically and then send
> it.
> 
> But here, I think again the XML is bad since it does not include the
> 2 bytes padding which are between the value_mask and the value_padding
> as you saw on specs.
> 
> So currently the struct generated as above is anyway mis-aligned (its
> size is 10) and the compiler adds 2 bytes to align it and set its size
> to 12.
> 
> Sorry if I'm wrong, I just try to really understand this stuff. :)

Yes, you're right.  My presumption that valueparam masks
properly is wrong.  In retrospect, I should have guessed
this; the code generator never autopads anything, and the
pad bytes aren't always necesary.

The fundamental bug, then, is in the XCB definition of
valueparam.  Sometimes there should be a pad between the
mask and the list of values, as in ConfigureWindow.
Sometimes there should not, as in CreateWindow.  The
"obvious" thing to do is to add an optional value-mask-pad
field to valueparam somewhere in proto/xcbgen/xtypes.py, and
then go through all the valueparam fields in the various
requests adding value-mask-pad="2" where needed.  I count
six of these in the core protocol and another nine
elsewhere, so this should be doable.

I'd do it tonight, but my Python and XML hacking skills
aren't quite up to trying it without a few hours in front of
me.

	Bart


More information about the Xcb mailing list