[Xcb] [PATCH proto 1/2] xkb: Work around alignment problem in GetNames reply

Ran Benita ran234 at gmail.com
Tue Jul 23 03:33:46 PDT 2013


The situation is: a list of CARD8s followed by a list of ATOMs (4
bytes). In the current code, the second list is aligned to 1 byte
according the size of the CARD8 list, so in effect it follows the first
list immediately. However, the second list needs to be aligned to 4 bytes
(see XkbPaddedSize in the server and Xlib).

Signed-off-by: Ran Benita <ran234 at gmail.com>
---
 src/xkb.xml | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Here's some test code I've used:
https://gist.github.com/bluetech/6061368

I've also tried to see if this can be fixed in the code generator rather
than the protocol file. But it seems like there's diparity among the
extensions on what to do here. It was discussed before:

http://lists.freedesktop.org/archives/xcb/2010-November/006575.html
https://bugs.freedesktop.org/show_bug.cgi?id=34037
http://lists.freedesktop.org/archives/xcb/2011-July/007157.html
(Also continues to other monthes)

So I've opted for the workaround (lifted from xf86vidmode.xml as
suggested on IRC).

diff --git a/src/xkb.xml b/src/xkb.xml
index 0e263c4..ca3a8b2 100644
--- a/src/xkb.xml
+++ b/src/xkb.xml
@@ -1350,6 +1350,20 @@ authorization from the authors.
 					<list name="acts_rtrn_count" type="CARD8">
 						<fieldref>nKeyActions</fieldref>
 					</list>
+					<list type="CARD8" name="alignment_pad">
+					    <op op="-">
+						<op op="&">
+						    <op op="+">
+							<fieldref>nKeyActions</fieldref>
+							<value>3</value>
+						    </op>
+						    <unop op="~">
+							<value>3</value>
+						    </unop>
+						</op>
+						<fieldref>nKeyActions</fieldref>
+					    </op>
+					</list>
 					<list name="acts_rtrn_acts" type="Action">
 						<fieldref>totalActions</fieldref>
 					</list>
@@ -1657,6 +1671,20 @@ authorization from the authors.
 					       <fieldref>nKTLevels</fieldref> -->
 					        <fieldref>nTypes</fieldref>
 					</list>
+					<list type="CARD8" name="alignment_pad">
+					    <op op="-">
+						<op op="&">
+						    <op op="+">
+							<fieldref>nTypes</fieldref>
+							<value>3</value>
+						    </op>
+						    <unop op="~">
+							<value>3</value>
+						    </unop>
+						</op>
+						<fieldref>nTypes</fieldref>
+					    </op>
+					</list>
 					<list name="ktLevelNames" type="ATOM">
 						<sumof ref="nLevelsPerType" />
 					</list>
-- 
1.8.3.3



More information about the Xcb mailing list