From 5e66fb64762b6d442a55d0506b07be18aeee7643 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 19 Mar 2023 13:51:24 -0700 Subject: Replace custom copy of GetReq macro with call to Xlib 1.5's _XGetRequest XvMCproto.h names don't match those required by the Xlibint.h GetReq* macros, but at least we can rely on the _XGetRequest function for the bulk of the work now, instead of duplicating it. Continues to use sizeof() instead of SIZEOF() due to stray ; on the end of many sz_* definitions in XvMCproto.h, but I've verified the sizes are the same with both methods. Also clears clang warnings that were repeated for every call: XvMC.c:79:5: warning: cast from 'char *' to 'xvmcQueryVersionReq *' increases required alignment from 1 to 2 [-Wcast-align] XvMCGetReq(QueryVersion, req); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./XvMClibint.h:16:8: note: expanded from macro 'XvMCGetReq' req = (xvmc##name##Req *)(dpy->last_req = dpy->bufptr);\ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ XvMC.c:79:5: warning: implicit conversion loses integer precision: 'int' to 'CARD8' (aka 'unsigned char') [-Wconversion] XvMCGetReq(QueryVersion, req); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./XvMClibint.h:17:30: note: expanded from macro 'XvMCGetReq' req->reqType = info->codes->major_opcode;\ ~ ~~~~~~~~~~~~~^~~~~~~~~~~~ Signed-off-by: Alan Coopersmith --- src/XvMClibint.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/XvMClibint.h b/src/XvMClibint.h index b21b966..a6ac5f2 100644 --- a/src/XvMClibint.h +++ b/src/XvMClibint.h @@ -9,16 +9,12 @@ #define XvMCCheckExtension(dpy, i, val) \ XextCheckExtension(dpy, i, xvmc_extension_name, val) +/* names in XvMCproto.h don't match the expectation of Xlib's GetReq* macros, + so we have to provide our own implementation */ #define XvMCGetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + sizeof(xvmc##name##Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xvmc##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = info->codes->major_opcode;\ - req->xvmcReqType = xvmc_##name; \ - req->length = sizeof(xvmc##name##Req)>>2;\ - dpy->bufptr += sizeof(xvmc##name##Req);\ - dpy->request++ + req = (xvmc##name##Req *) _XGetRequest( \ + dpy, (CARD8) info->codes->major_opcode, sizeof(xvmc##name##Req)); \ + req->xvmcReqType = xvmc_##name _XFUNCPROTOBEGIN -- cgit v1.2.3