glx: DoQueryContext(): determine reply length from buffer size
The reply length (in units as well as bytes) can safely be determined at compile time, by using sizeof() operator. No need for unnecessarily complicated shifting bits back and forth. 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
ef77c486d5
commit
ab4142bc75
|
@ -1660,7 +1660,6 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
|
||||||
ClientPtr client = cl->client;
|
ClientPtr client = cl->client;
|
||||||
__GLXcontext *ctx;
|
__GLXcontext *ctx;
|
||||||
CARD32 sendBuf[GLX_QUERY_NPROPS * 2];
|
CARD32 sendBuf[GLX_QUERY_NPROPS * 2];
|
||||||
int nReplyBytes;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err))
|
if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err))
|
||||||
|
@ -1669,11 +1668,10 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
|
||||||
xGLXQueryContextInfoEXTReply reply = {
|
xGLXQueryContextInfoEXTReply reply = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = GLX_QUERY_NPROPS << 1,
|
.length = bytes_to_int32(sizeof(sendBuf)),
|
||||||
.n = GLX_QUERY_NPROPS,
|
.n = GLX_QUERY_NPROPS,
|
||||||
};
|
};
|
||||||
|
|
||||||
nReplyBytes = reply.length << 2;
|
|
||||||
sendBuf[0] = GLX_SHARE_CONTEXT_EXT;
|
sendBuf[0] = GLX_SHARE_CONTEXT_EXT;
|
||||||
sendBuf[1] = (int) (ctx->share_id);
|
sendBuf[1] = (int) (ctx->share_id);
|
||||||
sendBuf[2] = GLX_VISUAL_ID_EXT;
|
sendBuf[2] = GLX_VISUAL_ID_EXT;
|
||||||
|
@ -1686,20 +1684,18 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
|
||||||
sendBuf[9] = (int) (ctx->renderType);
|
sendBuf[9] = (int) (ctx->renderType);
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
int length = reply.length;
|
|
||||||
|
|
||||||
__GLX_DECLARE_SWAP_VARIABLES;
|
__GLX_DECLARE_SWAP_VARIABLES;
|
||||||
__GLX_DECLARE_SWAP_ARRAY_VARIABLES;
|
__GLX_DECLARE_SWAP_ARRAY_VARIABLES;
|
||||||
__GLX_SWAP_SHORT(&reply.sequenceNumber);
|
__GLX_SWAP_SHORT(&reply.sequenceNumber);
|
||||||
__GLX_SWAP_INT(&reply.length);
|
__GLX_SWAP_INT(&reply.length);
|
||||||
__GLX_SWAP_INT(&reply.n);
|
__GLX_SWAP_INT(&reply.n);
|
||||||
WriteToClient(client, sizeof(xGLXQueryContextInfoEXTReply), &reply);
|
WriteToClient(client, sizeof(xGLXQueryContextInfoEXTReply), &reply);
|
||||||
__GLX_SWAP_INT_ARRAY(sendBuf, length);
|
__GLX_SWAP_INT_ARRAY(sendBuf, sizeof(sendBuf) / sizeof(CARD32));
|
||||||
WriteToClient(client, length << 2, sendBuf);
|
WriteToClient(client, sizeof(sendBuf), sendBuf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WriteToClient(client, sizeof(xGLXQueryContextInfoEXTReply), &reply);
|
WriteToClient(client, sizeof(xGLXQueryContextInfoEXTReply), &reply);
|
||||||
WriteToClient(client, nReplyBytes, sendBuf);
|
WriteToClient(client, sizeof(sendBuf), sendBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
|
|
Loading…
Reference in New Issue