glx: use sizeof() for reply struct
The reply struct's size can safely be determined by the sizeof() operator, so no need for using an extra define here. Making the code easier to read and also open the door for future convenience macros that might determine the buffer size on their own. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1665>
This commit is contained in:
parent
558ded4dbf
commit
6bd673ab15
|
@ -41,7 +41,7 @@ set_client_info(__GLXclientState * cl, xGLXSetClientInfoARBReq * req,
|
|||
/* Verify that the size of the packet matches the size inferred from the
|
||||
* sizes specified for the various fields.
|
||||
*/
|
||||
size = sz_xGLXSetClientInfoARBReq;
|
||||
size = sizeof(xGLXSetClientInfoARBReq);
|
||||
size = safe_add(size, safe_mul(req->numVersions, bytes_per_version));
|
||||
size = safe_add(size, safe_pad(req->numGLExtensionBytes));
|
||||
size = safe_add(size, safe_pad(req->numGLXExtensionBytes));
|
||||
|
|
|
@ -114,7 +114,7 @@ __glXDisp_CreateContextAttribsARB(__GLXclientState * cl, GLbyte * pc)
|
|||
/* Verify that the size of the packet matches the size inferred from the
|
||||
* sizes specified for the various fields.
|
||||
*/
|
||||
const unsigned expected_size = (sz_xGLXCreateContextAttribsARBReq
|
||||
const unsigned expected_size = (sizeof(xGLXCreateContextAttribsARBReq)
|
||||
+ (req->numAttribs * 8)) / 4;
|
||||
|
||||
if (req->length != expected_size)
|
||||
|
|
|
@ -720,7 +720,7 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc)
|
|||
__GLX_SWAP_SHORT(&reply.sequenceNumber);
|
||||
__GLX_SWAP_INT(&reply.length);
|
||||
}
|
||||
WriteToClient(client, sz_xGLXIsDirectReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXIsDirectReply), &reply);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
@ -759,7 +759,7 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc)
|
|||
__GLX_SWAP_INT(&reply.minorVersion);
|
||||
}
|
||||
|
||||
WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXQueryVersionReply), &reply);
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
@ -930,7 +930,7 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
|
|||
__GLX_SWAP_INT(&reply.numProps);
|
||||
}
|
||||
|
||||
WriteToClient(client, sz_xGLXGetVisualConfigsReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXGetVisualConfigsReply), &reply);
|
||||
|
||||
for (i = 0; i < pGlxScreen->numVisuals; i++) {
|
||||
modes = pGlxScreen->visuals[i];
|
||||
|
@ -1043,7 +1043,7 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen)
|
|||
__GLX_SWAP_INT(&reply.numAttribs);
|
||||
}
|
||||
|
||||
WriteToClient(client, sz_xGLXGetFBConfigsReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXGetFBConfigsReply), &reply);
|
||||
|
||||
for (modes = pGlxScreen->fbconfigs; modes != NULL; modes = modes->next) {
|
||||
p = 0;
|
||||
|
@ -1692,12 +1692,12 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
|
|||
__GLX_SWAP_SHORT(&reply.sequenceNumber);
|
||||
__GLX_SWAP_INT(&reply.length);
|
||||
__GLX_SWAP_INT(&reply.n);
|
||||
WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXQueryContextInfoEXTReply), &reply);
|
||||
__GLX_SWAP_INT_ARRAY((int *) sendBuf, length);
|
||||
WriteToClient(client, length << 2, sendBuf);
|
||||
}
|
||||
else {
|
||||
WriteToClient(client, sz_xGLXQueryContextInfoEXTReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXQueryContextInfoEXTReply), &reply);
|
||||
WriteToClient(client, nReplyBytes, sendBuf);
|
||||
}
|
||||
|
||||
|
@ -1935,12 +1935,12 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
|
|||
__GLX_SWAP_SHORT(&reply.sequenceNumber);
|
||||
__GLX_SWAP_INT(&reply.length);
|
||||
__GLX_SWAP_INT(&reply.numAttribs);
|
||||
WriteToClient(client, sz_xGLXGetDrawableAttributesReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXGetDrawableAttributesReply), &reply);
|
||||
__GLX_SWAP_INT_ARRAY((int *) attributes, length);
|
||||
WriteToClient(client, length << 2, attributes);
|
||||
}
|
||||
else {
|
||||
WriteToClient(client, sz_xGLXGetDrawableAttributesReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXGetDrawableAttributesReply), &reply);
|
||||
WriteToClient(client, reply.length * sizeof(CARD32), attributes);
|
||||
}
|
||||
|
||||
|
@ -2020,8 +2020,8 @@ __glXDisp_Render(__GLXclientState * cl, GLbyte * pc)
|
|||
}
|
||||
|
||||
commandsDone = 0;
|
||||
pc += sz_xGLXRenderReq;
|
||||
left = (req->length << 2) - sz_xGLXRenderReq;
|
||||
pc += sizeof(xGLXRenderReq);
|
||||
left = (req->length << 2) - sizeof(xGLXRenderReq);
|
||||
while (left > 0) {
|
||||
__GLXrenderSizeData entry;
|
||||
int extra = 0;
|
||||
|
@ -2130,18 +2130,18 @@ __glXDisp_RenderLarge(__GLXclientState * cl, GLbyte * pc)
|
|||
/*
|
||||
** Check the request length.
|
||||
*/
|
||||
if ((req->length << 2) != safe_pad(dataBytes) + sz_xGLXRenderLargeReq) {
|
||||
if ((req->length << 2) != safe_pad(dataBytes) + sizeof(xGLXRenderLargeReq)) {
|
||||
client->errorValue = req->length;
|
||||
/* Reset in case this isn't 1st request. */
|
||||
ResetLargeCommandStatus(glxc);
|
||||
return BadLength;
|
||||
}
|
||||
pc += sz_xGLXRenderLargeReq;
|
||||
pc += sizeof(xGLXRenderLargeReq);
|
||||
|
||||
if (glxc->largeCmdRequestsSoFar == 0) {
|
||||
__GLXrenderSizeData entry;
|
||||
int extra = 0;
|
||||
int left = (req->length << 2) - sz_xGLXRenderLargeReq;
|
||||
int left = (req->length << 2) - sizeof(xGLXRenderLargeReq);
|
||||
int cmdlen;
|
||||
int err;
|
||||
|
||||
|
@ -2396,12 +2396,12 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
|
|||
__GLX_SWAP_SHORT(&reply.sequenceNumber);
|
||||
__GLX_SWAP_INT(&reply.length);
|
||||
__GLX_SWAP_INT(&reply.n);
|
||||
WriteToClient(client, sz_xGLXQueryExtensionsStringReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXQueryExtensionsStringReply), &reply);
|
||||
__GLX_SWAP_INT_ARRAY((int *) buf, length);
|
||||
WriteToClient(client, length << 2, buf);
|
||||
}
|
||||
else {
|
||||
WriteToClient(client, sz_xGLXQueryExtensionsStringReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXQueryExtensionsStringReply), &reply);
|
||||
WriteToClient(client, (int) (length << 2), buf);
|
||||
}
|
||||
|
||||
|
@ -2468,13 +2468,13 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc)
|
|||
__GLX_SWAP_SHORT(&reply.sequenceNumber);
|
||||
__GLX_SWAP_INT(&reply.length);
|
||||
__GLX_SWAP_INT(&reply.n);
|
||||
WriteToClient(client, sz_xGLXQueryServerStringReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXQueryServerStringReply), &reply);
|
||||
/** no swap is needed for an array of chars **/
|
||||
/* __GLX_SWAP_INT_ARRAY((int *)buf, length); */
|
||||
WriteToClient(client, length << 2, buf);
|
||||
}
|
||||
else {
|
||||
WriteToClient(client, sz_xGLXQueryServerStringReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXQueryServerStringReply), &reply);
|
||||
WriteToClient(client, (int) (length << 2), buf);
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ __glXSendReply(ClientPtr client, const void *data, size_t elements,
|
|||
*/
|
||||
|
||||
(void) memcpy(&reply.pad3, data, 8);
|
||||
WriteToClient(client, sz_xGLXSingleReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXSingleReply), &reply);
|
||||
|
||||
if (reply_ints != 0) {
|
||||
WriteToClient(client, reply_ints * 4, data);
|
||||
|
@ -183,7 +183,7 @@ __glXSendReplySwap(ClientPtr client, const void *data, size_t elements,
|
|||
*/
|
||||
|
||||
(void) memcpy(&reply.pad3, data, 8);
|
||||
WriteToClient(client, sz_xGLXSingleReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXSingleReply), &reply);
|
||||
|
||||
if (reply_ints != 0) {
|
||||
WriteToClient(client, reply_ints * 4, data);
|
||||
|
|
|
@ -198,7 +198,7 @@ __glXDisp_RenderMode(__GLXclientState * cl, GLbyte * pc)
|
|||
.size = nitems,
|
||||
.newMode = newMode
|
||||
};
|
||||
WriteToClient(client, sz_xGLXRenderModeReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXRenderModeReply), &reply);
|
||||
if (retBytes) {
|
||||
WriteToClient(client, retBytes, retBuffer);
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc)
|
|||
__GLX_SWAP_INT(&reply.retval);
|
||||
__GLX_SWAP_INT(&reply.size);
|
||||
__GLX_SWAP_INT(&reply.newMode);
|
||||
WriteToClient(client, sz_xGLXRenderModeReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXRenderModeReply), &reply);
|
||||
if (retBytes) {
|
||||
WriteToClient(client, retBytes, retBuffer);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
reply.sequenceNumber = client->sequence;
|
||||
|
||||
#define __GLX_SEND_HEADER() \
|
||||
WriteToClient (client, sz_xGLXSingleReply, &reply);
|
||||
WriteToClient (client, sizeof(xGLXSingleReply), &reply);
|
||||
|
||||
#define __GLX_PUT_RETVAL(a) \
|
||||
reply.retval = (a);
|
||||
|
|
|
@ -110,7 +110,7 @@ static int dispatch_GLXQueryVersion(ClientPtr client)
|
|||
reply.majorVersion = GlxCheckSwap(client, 1);
|
||||
reply.minorVersion = GlxCheckSwap(client, 4);
|
||||
|
||||
WriteToClient(client, sz_xGLXQueryVersionReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXQueryVersionReply), &reply);
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ static int CommonMakeCurrent(ClientPtr client,
|
|||
}
|
||||
|
||||
reply.contextTag = GlxCheckSwap(client, reply.contextTag);
|
||||
WriteToClient(client, sz_xGLXMakeCurrentReply, &reply);
|
||||
WriteToClient(client, sizeof(xGLXMakeCurrentReply), &reply);
|
||||
return Success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue