[Xcb] ping: SetFontPath specification bug?

Ian Osgood iano at quirkster.com
Thu Jul 3 10:59:20 PDT 2008


On Jul 3, 2008, at 9:29 AM, Thien-Thi Nguyen wrote:

> Could someone confirm/deny this bug report?
>
>   http://lists.freedesktop.org/archives/xcb/2008-June/003577.html
>
> thi

Where did you obtain "X Protocol document PROTO.pdf"? The only online  
X Protocol documents I know about are drafts and obsolete. (We would  
like to link to current documentation from the XCB wiki.)

 > ...and also from watching the protocol on the wire using xset +  
xmon...

That pretty much says you have the correct bug fix (assuming you  
rebuilt the sources and looked at the protocol again). However...

We use the current X proto header files as the final authority on  
protocol questions. For this bug, the source is in xorg/proto/ 
x11proto/Xproto.h:

typedef struct {
     CARD8 reqType;
     BYTE pad;
     CARD16 length B16;
     CARD16 nFonts B16;
     BYTE pad1, pad2;    /* LISTofSTRING8 follows on word boundary */
} xSetFontPathReq;

Which seems to match our generated code in libxcb/src/xproto.h

typedef struct xcb_set_font_path_request_t {
     uint8_t  major_opcode; /**<  */
     uint8_t  pad0; /**<  */
     uint16_t length; /**<  */
     uint16_t font_qty; /**<  */
} xcb_set_font_path_request_t;

and libxcb/src/xproto.c

xcb_void_cookie_t
xcb_set_font_path (xcb_connection_t *c  /**< */,
                    uint16_t          font_qty  /**< */,
                    uint32_t          path_len  /**< */,
                    const char       *path  /**< */)
{
     static const xcb_protocol_request_t xcb_req = {
         /* count */ 4,
         /* ext */ 0,
         /* opcode */ XCB_SET_FONT_PATH,
         /* isvoid */ 1
     };

     struct iovec xcb_parts[6];
     xcb_void_cookie_t xcb_ret;
     xcb_set_font_path_request_t xcb_out;

     xcb_out.pad0 = 0;
     xcb_out.font_qty = font_qty;

     xcb_parts[2].iov_base = (char *) &xcb_out;
     xcb_parts[2].iov_len = sizeof(xcb_out);
     xcb_parts[3].iov_base = 0;
     xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;
     xcb_parts[4].iov_base = (char *) path;
     xcb_parts[4].iov_len = path_len * sizeof(char);
     xcb_parts[5].iov_base = 0;
     xcb_parts[5].iov_len = -xcb_parts[4].iov_len & 3;
     xcb_ret.sequence = xcb_send_request(c, 0, xcb_parts + 2, &xcb_req);
     return xcb_ret;
}

The xcb_parts[3] should generate the same padding as is defined by  
BYTE pad1, pad2; in Xproto.h.  (This code generation requires proto  
structs to be fully byte packed in order for sizeof(xcb_out) to  
return the correct size.)

(NOTE: this is the code generated by the last version of the XSLT in  
libxcb/src/c-client.xsl. Which code generator were you using? I have  
no idea how well the newer Python generators have been validated.  
Perhaps the Python generator has a bug in its <list> handler.)

Ian



More information about the Xcb mailing list