[Xcb] [PATCH libxcb 4/4 V2] generator: fix align-pads for switches which start at unaligned pos

Christian Linhart chris at DemoRecorder.com
Wed Sep 10 01:00:24 PDT 2014

On 09/09/14 23:40, Ran Benita wrote:
> On Tue, Sep 09, 2014 at 07:50:28PM +0200, Christian Linhart wrote:
>> [snip]
>> I hope I could explain this in a comprehensible way.
> Thanks for the detailed explanation. That made things clear.
You are welcome.

> The proposed solution is acceptable, at least I can't see why it
> wouldn't work. I defer to you and Peter on the safety of it.
>> Footnotes:
>> [1] Above, I write "somehow" because xcb_block_len 
>>     is set to 0 after an align-pad. 
>>     This probably creates other problems,
>>     when a 2-byte align is later followed by 4-byte align.
> I'd be pretty surprised to ever see a <pad align!=4>.
Yes, you are probably right
But the xcb_block_len is also set to 0 by the implicit align-pad code.
So this might occur somewhere. 
So, the padding issue may need further work later.
But we know that anyways I guess. :-)

>>>> Example:
>>>> struct InputState, where the switch starts after two 1-byte fields,
>>>> which is a 2 byte offset for 4-byte and 8-byte alignment.
>>>> The previous problem can be demonstrated when adding a
>>>> <pad align="4"/> at the end of case "key".
> Well, if the pad-align here is really needed, I would have opted for the
> easy way of just putting it after the switch. 
It's not possible to put something after the switch because a switch
has to be the last element of a struct, request, reply, etc.

Also, we still have the implicit padding code which may do the same as
an explicit pad.

> But fixing this properly
> is better.


More information about the Xcb mailing list