[Xcb] [PATCH proto 4/9] xprint: make padding explicit

Christian Linhart chris at demorecorder.com
Sun Sep 13 06:45:12 PDT 2015

Add explicit padding for:
* the struct "PRINTER":
  - between list "name" and field "descLen"
    I cannot read any of the formats that the xproto-spec is provided in.
    (the postscript file is broken)
    Therefore I provide the Xlib implementation as a reference:
    The list "name" is read with _XReadPad or _XEatData:
    _XReadPad does 4-byte padding:
    _XEatData does not do 4-byte padding:
    Since _XEatData is only a fallback when malloc fails, this is usually not
    used. Therefore, using _XEatData as an alternative to _XReadPad in libXp
    is a bug there.

  - at the end of the struct "PRINTER"
    this is OK because of the same reasons as above:

* the reply of request "PrintInputSelected"
  - add a 1-byte pad at the start.
    This is needed because all replies start with a 1-byte field that occupies
    a place in the reply-header.

Signed-off-by: Christian Linhart <chris at demorecorder.com>
 src/xprint.xml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/xprint.xml b/src/xprint.xml
index 4da49b0..f9af65f 100644
--- a/src/xprint.xml
+++ b/src/xprint.xml
@@ -37,20 +37,20 @@
     <!-- Types -->
     <struct name="PRINTER">
         <field type="CARD32" name="nameLen" />
         <list type="STRING8" name="name">
-        <!-- Padding -->
+        <pad align="4" />
         <field type="CARD32" name="descLen" />
         <list type="STRING8" name="description">
-        <!-- More padding -->
+        <pad align="4" />
     <!--<typedef oldname="CARD32" newname="PCONTEXT" />-->
     <xidtype name="PCONTEXT" />
     <!-- "PrintGetDocumentData" -->
     <enum name="GetDoc">
@@ -215,14 +215,15 @@ <request name="PrintSelectInput" opcode="15">
         <field type="PCONTEXT" name="context" />
         <field type="CARD32" name="event_mask" />
     <request name="PrintInputSelected" opcode="16">
         <field type="PCONTEXT" name="context" />
+           <pad bytes="1" />
            <field type="CARD32" name="event_mask" />
            <field type="CARD32" name="all_events_mask" />
     <request name="PrintGetAttributes" opcode="17">
         <field type="PCONTEXT" name="context" />

More information about the Xcb mailing list