dri3: use REPLY_*() macros for preparing / sending replies

Use the new macros for preparing and sending replies to clients.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-15 14:04:16 +02:00
parent 9c6271258c
commit 95301df1a9

View File

@ -69,8 +69,6 @@ proc_dri3_query_version(ClientPtr client)
REQUEST_FIELD_CARD32(minorVersion); REQUEST_FIELD_CARD32(minorVersion);
xDRI3QueryVersionReply rep = { xDRI3QueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.majorVersion = SERVER_DRI3_MAJOR_VERSION, .majorVersion = SERVER_DRI3_MAJOR_VERSION,
.minorVersion = SERVER_DRI3_MINOR_VERSION .minorVersion = SERVER_DRI3_MINOR_VERSION
}; };
@ -111,38 +109,24 @@ proc_dri3_query_version(ClientPtr client)
rep.minorVersion = stuff->minorVersion; rep.minorVersion = stuff->minorVersion;
} }
if (client->swapped) { REPLY_FIELD_CARD32(majorVersion);
swaps(&rep.sequenceNumber); REPLY_FIELD_CARD32(minorVersion);
swapl(&rep.length); REPLY_SEND_RET_SUCCESS();
swapl(&rep.majorVersion);
swapl(&rep.minorVersion);
}
WriteToClient(client, sizeof(rep), &rep);
return Success;
} }
int int
dri3_send_open_reply(ClientPtr client, int fd) dri3_send_open_reply(ClientPtr client, int fd)
{ {
xDRI3OpenReply rep = { xDRI3OpenReply rep = {
.type = X_Reply,
.nfd = 1, .nfd = 1,
.sequenceNumber = client->sequence,
}; };
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
if (WriteFdToClient(client, fd, TRUE) < 0) { if (WriteFdToClient(client, fd, TRUE) < 0) {
close(fd); close(fd);
return BadAlloc; return BadAlloc;
} }
WriteToClient(client, sizeof (rep), &rep); REPLY_SEND_RET_SUCCESS();
return Success;
} }
static int static int
@ -278,9 +262,7 @@ proc_dri3_buffer_from_pixmap(ClientPtr client)
} }
xDRI3BufferFromPixmapReply rep = { xDRI3BufferFromPixmapReply rep = {
.type = X_Reply,
.nfd = 1, .nfd = 1,
.sequenceNumber = client->sequence,
.width = pixmap->drawable.width, .width = pixmap->drawable.width,
.height = pixmap->drawable.height, .height = pixmap->drawable.height,
.depth = pixmap->drawable.depth, .depth = pixmap->drawable.depth,
@ -291,22 +273,16 @@ proc_dri3_buffer_from_pixmap(ClientPtr client)
if (fd < 0) if (fd < 0)
return BadPixmap; return BadPixmap;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
swapl(&rep.size);
swaps(&rep.width);
swaps(&rep.height);
swaps(&rep.stride);
}
if (WriteFdToClient(client, fd, TRUE) < 0) { if (WriteFdToClient(client, fd, TRUE) < 0) {
close(fd); close(fd);
return BadAlloc; return BadAlloc;
} }
WriteToClient(client, sizeof(rep), &rep); REPLY_FIELD_CARD32(size);
REPLY_FIELD_CARD16(width);
return Success; REPLY_FIELD_CARD16(height);
REPLY_FIELD_CARD16(stride);
REPLY_SEND_RET_SUCCESS();
} }
static int static int
@ -345,10 +321,9 @@ proc_dri3_fd_from_fence(ClientPtr client)
REQUEST_FIELD_CARD32(fence); REQUEST_FIELD_CARD32(fence);
xDRI3FDFromFenceReply rep = { xDRI3FDFromFenceReply rep = {
.type = X_Reply,
.nfd = 1, .nfd = 1,
.sequenceNumber = client->sequence,
}; };
DrawablePtr drawable; DrawablePtr drawable;
int fd; int fd;
int status; int status;
@ -365,16 +340,10 @@ proc_dri3_fd_from_fence(ClientPtr client)
if (fd < 0) if (fd < 0)
return BadMatch; return BadMatch;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
}
if (WriteFdToClient(client, fd, FALSE) < 0) if (WriteFdToClient(client, fd, FALSE) < 0)
return BadAlloc; return BadAlloc;
WriteToClient(client, sizeof(rep), &rep); REPLY_SEND_RET_SUCCESS();
return Success;
} }
static int static int
@ -390,7 +359,6 @@ proc_dri3_get_supported_modifiers(ClientPtr client)
CARD32 nwindowmodifiers = 0; CARD32 nwindowmodifiers = 0;
CARD32 nscreenmodifiers = 0; CARD32 nscreenmodifiers = 0;
int status; int status;
int i;
status = dixLookupWindow(&window, stuff->window, client, DixGetAttrAccess); status = dixLookupWindow(&window, stuff->window, client, DixGetAttrAccess);
if (status != Success) if (status != Success)
@ -410,24 +378,14 @@ proc_dri3_get_supported_modifiers(ClientPtr client)
free(screen_modifiers); free(screen_modifiers);
xDRI3GetSupportedModifiersReply rep = { xDRI3GetSupportedModifiersReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.numWindowModifiers = nwindowmodifiers, .numWindowModifiers = nwindowmodifiers,
.numScreenModifiers = nscreenmodifiers, .numScreenModifiers = nscreenmodifiers,
.length = bytes_to_int32(sizeof(buf)),
}; };
if (client->swapped) { REPLY_FIELD_CARD32(numWindowModifiers);
swaps(&rep.sequenceNumber); REPLY_FIELD_CARD32(numScreenModifiers);
swapl(&rep.length); REPLY_BUF_CARD64(buf, nwindowmodifiers+nscreenmodifiers);
swapl(&rep.numWindowModifiers); REPLY_SEND_EXTRA(buf, sizeof(buf));
swapl(&rep.numScreenModifiers);
for (i = 0; i < nwindowmodifiers+nscreenmodifiers; i++)
swapll(&buf[i]);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, sizeof(buf), buf);
return Success; return Success;
} }
@ -575,10 +533,7 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
memcpy(&buf[num_fds], offsets, num_fds * sizeof(CARD32)); memcpy(&buf[num_fds], offsets, num_fds * sizeof(CARD32));
xDRI3BuffersFromPixmapReply rep = { xDRI3BuffersFromPixmapReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.nfd = num_fds, .nfd = num_fds,
.length = bytes_to_int32(sizeof(buf)),
.width = pixmap->drawable.width, .width = pixmap->drawable.width,
.height = pixmap->drawable.height, .height = pixmap->drawable.height,
.depth = pixmap->drawable.depth, .depth = pixmap->drawable.depth,
@ -586,20 +541,11 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
.modifier = modifier, .modifier = modifier,
}; };
if (client->swapped) { REPLY_FIELD_CARD16(width);
swaps(&rep.sequenceNumber); REPLY_FIELD_CARD16(height);
swapl(&rep.length); REPLY_FIELD_CARD64(modifier);
swaps(&rep.width); REPLY_BUF_CARD32(buf, num_fds * 2);
swaps(&rep.height); REPLY_SEND_RET_SUCCESS();
swapll(&rep.modifier);
for (i = 0; i < num_fds * 2; i++)
swapl(&buf[i]);
}
WriteToClient(client, sizeof(rep), &rep);
WriteToClient(client, sizeof(buf), buf);
return Success;
} }
static int static int