xfree86: dri: use X_SEND_REPLY_SIMPLE() for simple replies

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2025-08-29 16:39:00 +02:00
committed by Enrico Weigelt
parent a27f18d1c6
commit 286a15de4c
2 changed files with 27 additions and 89 deletions

View File

@@ -77,9 +77,6 @@ static int
ProcXF86DRIQueryVersion(register ClientPtr client)
{
xXF86DRIQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_XF86DRI_MAJOR_VERSION,
.minorVersion = SERVER_XF86DRI_MINOR_VERSION,
.patchVersion = SERVER_XF86DRI_PATCH_VERSION
@@ -87,20 +84,16 @@ ProcXF86DRIQueryVersion(register ClientPtr client)
REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swaps(&rep.majorVersion);
swaps(&rep.minorVersion);
swapl(&rep.patchVersion);
}
WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), &rep);
return Success;
return X_SEND_REPLY_SIMPLE(client, rep);
}
static int
ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
{
xXF86DRIQueryDirectRenderingCapableReply rep;
Bool isCapable;
REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
@@ -118,22 +111,11 @@ ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
if (!client->local || client->swapped)
isCapable = 0;
rep = (xXF86DRIQueryDirectRenderingCapableReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xXF86DRIQueryDirectRenderingCapableReply reply = {
.isCapable = isCapable
};
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
WriteToClient(client,
sizeof(xXF86DRIQueryDirectRenderingCapableReply),
&rep);
return Success;
return X_SEND_REPLY_SIMPLE(client, reply);
}
static int
@@ -183,13 +165,6 @@ ProcXF86DRIOpenConnection(register ClientPtr client)
static int
ProcXF86DRIAuthConnection(register ClientPtr client)
{
xXF86DRIAuthConnectionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.authenticated = 1
};
REQUEST(xXF86DRIAuthConnectionReq);
REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
if (stuff->screen >= screenInfo.numScreens) {
@@ -197,12 +172,17 @@ ProcXF86DRIAuthConnection(register ClientPtr client)
return BadValue;
}
CARD8 authenticated = 1;
if (!DRIAuthConnection(screenInfo.screens[stuff->screen], stuff->magic)) {
ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic);
rep.authenticated = 0;
authenticated = 0;
}
WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), &rep);
return Success;
xXF86DRIAuthConnectionReply rep = {
.authenticated = authenticated
};
return X_SEND_REPLY_SIMPLE(client, rep);
}
static int
@@ -257,13 +237,6 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client)
static int
ProcXF86DRICreateContext(register ClientPtr client)
{
xXF86DRICreateContextReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
ScreenPtr pScreen;
REQUEST(xXF86DRICreateContextReq);
REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
if (stuff->screen >= screenInfo.numScreens) {
@@ -271,7 +244,8 @@ ProcXF86DRICreateContext(register ClientPtr client)
return BadValue;
}
pScreen = screenInfo.screens[stuff->screen];
ScreenPtr pScreen = screenInfo.screens[stuff->screen];
xXF86DRICreateContextReply rep = { 0 };
if (!DRICreateContext(pScreen,
NULL,
@@ -279,8 +253,7 @@ ProcXF86DRICreateContext(register ClientPtr client)
return BadValue;
}
WriteToClient(client, sizeof(xXF86DRICreateContextReply), &rep);
return Success;
return X_SEND_REPLY_SIMPLE(client, rep);
}
static int
@@ -303,11 +276,6 @@ ProcXF86DRIDestroyContext(register ClientPtr client)
static int
ProcXF86DRICreateDrawable(ClientPtr client)
{
xXF86DRICreateDrawableReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
DrawablePtr pDrawable;
int rc;
@@ -323,13 +291,13 @@ ProcXF86DRICreateDrawable(ClientPtr client)
if (rc != Success)
return rc;
xXF86DRICreateDrawableReply rep = { 0 };
if (!DRICreateDrawable(screenInfo.screens[stuff->screen], client,
pDrawable, (drm_drawable_t *) &rep.hHWDrawable)) {
return BadValue;
}
WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), &rep);
return Success;
return X_SEND_REPLY_SIMPLE(client, rep);
}
static int

View File

@@ -75,9 +75,6 @@ static int
ProcDRI2QueryVersion(ClientPtr client)
{
xDRI2QueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
.majorVersion = dri2_major,
.minorVersion = dri2_minor
};
@@ -85,15 +82,11 @@ ProcDRI2QueryVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xDRI2QueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.majorVersion);
swapl(&rep.minorVersion);
}
WriteToClient(client, sizeof(xDRI2QueryVersionReply), &rep);
return Success;
return X_SEND_REPLY_SIMPLE(client, rep);
}
static int
@@ -138,7 +131,6 @@ static int
ProcDRI2Authenticate(ClientPtr client)
{
REQUEST(xDRI2AuthenticateReq);
xDRI2AuthenticateReply rep;
DrawablePtr pDraw;
int status;
@@ -147,15 +139,11 @@ ProcDRI2Authenticate(ClientPtr client)
&pDraw, &status))
return status;
rep = (xDRI2AuthenticateReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
xDRI2AuthenticateReply reply = {
.authenticated = DRI2Authenticate(client, pDraw->pScreen, stuff->magic)
};
WriteToClient(client, sizeof(xDRI2AuthenticateReply), &rep);
return Success;
return X_SEND_REPLY_SIMPLE(client, reply);
}
static void
@@ -322,7 +310,6 @@ static int
ProcDRI2CopyRegion(ClientPtr client)
{
REQUEST(xDRI2CopyRegionReq);
xDRI2CopyRegionReply rep;
DrawablePtr pDrawable;
int status;
RegionPtr pRegion;
@@ -346,15 +333,8 @@ ProcDRI2CopyRegion(ClientPtr client)
* that yet.
*/
rep = (xDRI2CopyRegionReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
WriteToClient(client, sizeof(xDRI2CopyRegionReply), &rep);
return Success;
xDRI2CopyRegionReply reply = { 0 };
return X_SEND_REPLY_SIMPLE(client, reply);
}
static void
@@ -393,11 +373,6 @@ static int
ProcDRI2SwapBuffers(ClientPtr client)
{
REQUEST(xDRI2SwapBuffersReq);
xDRI2SwapBuffersReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
DrawablePtr pDrawable;
CARD64 target_msc, divisor, remainder, swap_target;
int status;
@@ -424,11 +399,11 @@ ProcDRI2SwapBuffers(ClientPtr client)
if (status != Success)
return BadDrawable;
load_swap_reply(&rep, swap_target);
xDRI2SwapBuffersReply reply = { 0 };
WriteToClient(client, sizeof(xDRI2SwapBuffersReply), &rep);
load_swap_reply(&reply, swap_target);
return Success;
return X_SEND_REPLY_SIMPLE(client, reply);
}
static void
@@ -446,11 +421,6 @@ static int
ProcDRI2GetMSC(ClientPtr client)
{
REQUEST(xDRI2GetMSCReq);
xDRI2MSCReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0
};
DrawablePtr pDrawable;
CARD64 ust, msc, sbc;
int status;
@@ -465,11 +435,11 @@ ProcDRI2GetMSC(ClientPtr client)
if (status != Success)
return status;
load_msc_reply(&rep, ust, msc, sbc);
xDRI2MSCReply reply = { 0 };
WriteToClient(client, sizeof(xDRI2MSCReply), &rep);
load_msc_reply(&reply, ust, msc, sbc);
return Success;
return X_SEND_REPLY_SIMPLE(client, reply);
}
static int