[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:
       http://cgit.freedesktop.org/xorg/lib/libXp/tree/src/XpPrinter.c?id=libXp-1.0.3#n158
    _XReadPad does 4-byte padding:
       http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/xcb_io.c?id=libX11-1.6.3#n743
    _XEatData does not do 4-byte padding:
       http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/xcb_io.c?id=libX11-1.6.3#n755
    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:
       http://cgit.freedesktop.org/xorg/lib/libXp/tree/src/XpPrinter.c?id=libXp-1.0.3#n181

* 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">
             <fieldref>nameLen</fieldref>
         </list>
-        <!-- Padding -->
+        <pad align="4" />
         <field type="CARD32" name="descLen" />
         <list type="STRING8" name="description">
             <fieldref>descLen</fieldref>
         </list>
-        <!-- More padding -->
+        <pad align="4" />
     </struct>
 
     <!--<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>
 
     <request name="PrintInputSelected" opcode="16">
         <field type="PCONTEXT" name="context" />
         <reply>
+           <pad bytes="1" />
            <field type="CARD32" name="event_mask" />
            <field type="CARD32" name="all_events_mask" />
         </reply>
     </request>
 
     <request name="PrintGetAttributes" opcode="17">
         <field type="PCONTEXT" name="context" />
-- 
2.1.4



More information about the Xcb mailing list