[Xcb] [PATCH] Remove fieldref from sole list in GetIndicatorMap reply

Peter Harris pharris at opentext.com
Thu Feb 21 10:57:14 PST 2013


On 2013-02-21 12:45, Daniel Martin wrote:
> On Tue, Feb 19, 2013 at 02:22:43PM -0500, Peter Harris wrote:
>> On 2013-02-19 13:59, Daniel Martin wrote:
>> That's... annoying. <list /> works properly in requests (and in replies
>> in the app I was targeting, which wasn't libxcb).
> 
> <list />s are working in libxcb, because there's the assumption that
> they are in a request and therefor an additional ..._len parameter will
> be used in the function generating the request.
> 
>>> And the server doesn't set the 'length' field 1:1 to the length of the
>>> list.
>>
>> <list /> knows (or should know) that already.
>>
>> Is there any chance that fixing <list /> for replies is trivial? If not,
> 
> Just tried and for this case it's simple (see the attachment).

Thanks!

I think it needs a bit of tweaking. 'length' isn't the number of elements.

The number of elements is

(32 + length*4 - sizeof(everything_else)) / sizeof(elt)

[In this specific case, sizeof(everything_else) is 32, and sizeof(elt)
is sizeof(IndicatorMap) is 12, so we can reduce it to <op>length / 3
</op>, but the generator should use the more general case calculation]

> But, it's
> more difficult if the list is hidden in struct. There're such cases i.e.
> in xkb. (I'll have a second look at it when my fever is gone completly.)

A list in a struct is, by definition, not the only list in a
request/reply. (It may be, if the struct is used as a singleton, but in
general it should have been inlined anyway in that case. Structs are
primarily useful as targets of lists).

Since the <list> in the struct has to have a (working) fieldref to be
useful anyway, I don't think we need to worry about that case.

>> I'll re-submit the patch using <op> as per your suggestion.
> 
> Another more simply solution would be to use the 'which' field. Didn't
> noticed it at first. It's the bitmask saying which indicator is set and
> the <popcount> of it would give what you want.

I'd prefer to use the length field for this workaround, as that's what
Xlib does.

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