dri3: use static reply struct init on declaration
Make the code a bit easier to read by using initialization of the reply structs, at the point of declaration. Most of them aren't written to later, just passed into WriteReplyToClient(). Also dropping some useless zero assignments (struct initializers automatically zero-out unmentioned fields). Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
fbeee675fc
commit
ea78435fdd
|
@ -64,10 +64,10 @@ static int
|
|||
proc_dri3_query_version(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3QueryVersionReq);
|
||||
|
||||
xDRI3QueryVersionReply rep = {
|
||||
.type = X_Reply,
|
||||
.sequenceNumber = client->sequence,
|
||||
.length = 0,
|
||||
.majorVersion = SERVER_DRI3_MAJOR_VERSION,
|
||||
.minorVersion = SERVER_DRI3_MINOR_VERSION
|
||||
};
|
||||
|
@ -127,7 +127,6 @@ dri3_send_open_reply(ClientPtr client, int fd)
|
|||
.type = X_Reply,
|
||||
.nfd = 1,
|
||||
.sequenceNumber = client->sequence,
|
||||
.length = 0,
|
||||
};
|
||||
|
||||
if (client->swapped) {
|
||||
|
@ -257,12 +256,7 @@ static int
|
|||
proc_dri3_buffer_from_pixmap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3BufferFromPixmapReq);
|
||||
xDRI3BufferFromPixmapReply rep = {
|
||||
.type = X_Reply,
|
||||
.nfd = 1,
|
||||
.sequenceNumber = client->sequence,
|
||||
.length = 0,
|
||||
};
|
||||
|
||||
int rc;
|
||||
int fd;
|
||||
PixmapPtr pixmap;
|
||||
|
@ -275,10 +269,15 @@ proc_dri3_buffer_from_pixmap(ClientPtr client)
|
|||
return rc;
|
||||
}
|
||||
|
||||
rep.width = pixmap->drawable.width;
|
||||
rep.height = pixmap->drawable.height;
|
||||
rep.depth = pixmap->drawable.depth;
|
||||
rep.bpp = pixmap->drawable.bitsPerPixel;
|
||||
xDRI3BufferFromPixmapReply rep = {
|
||||
.type = X_Reply,
|
||||
.nfd = 1,
|
||||
.sequenceNumber = client->sequence,
|
||||
.width = pixmap->drawable.width,
|
||||
.height = pixmap->drawable.height,
|
||||
.depth = pixmap->drawable.depth,
|
||||
.bpp = pixmap->drawable.bitsPerPixel,
|
||||
};
|
||||
|
||||
fd = dri3_fd_from_pixmap(pixmap, &rep.stride, &rep.size);
|
||||
if (fd < 0)
|
||||
|
@ -336,7 +335,6 @@ proc_dri3_fd_from_fence(ClientPtr client)
|
|||
.type = X_Reply,
|
||||
.nfd = 1,
|
||||
.sequenceNumber = client->sequence,
|
||||
.length = 0,
|
||||
};
|
||||
DrawablePtr drawable;
|
||||
int fd;
|
||||
|
@ -372,10 +370,6 @@ static int
|
|||
proc_dri3_get_supported_modifiers(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3GetSupportedModifiersReq);
|
||||
xDRI3GetSupportedModifiersReply rep = {
|
||||
.type = X_Reply,
|
||||
.sequenceNumber = client->sequence,
|
||||
};
|
||||
WindowPtr window;
|
||||
ScreenPtr pScreen;
|
||||
CARD64 *window_modifiers = NULL;
|
||||
|
@ -397,10 +391,14 @@ proc_dri3_get_supported_modifiers(ClientPtr client)
|
|||
&nwindowmodifiers, &window_modifiers,
|
||||
&nscreenmodifiers, &screen_modifiers);
|
||||
|
||||
rep.numWindowModifiers = nwindowmodifiers;
|
||||
rep.numScreenModifiers = nscreenmodifiers;
|
||||
rep.length = bytes_to_int32(rep.numWindowModifiers * sizeof(CARD64)) +
|
||||
bytes_to_int32(rep.numScreenModifiers * sizeof(CARD64));
|
||||
xDRI3GetSupportedModifiersReply rep = {
|
||||
.type = X_Reply,
|
||||
.sequenceNumber = client->sequence,
|
||||
.numWindowModifiers = nwindowmodifiers,
|
||||
.numScreenModifiers = nscreenmodifiers,
|
||||
.length = bytes_to_int32(nwindowmodifiers * sizeof(CARD64)) +
|
||||
bytes_to_int32(nscreenmodifiers * sizeof(CARD64)),
|
||||
};
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
|
@ -521,10 +519,6 @@ static int
|
|||
proc_dri3_buffers_from_pixmap(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDRI3BuffersFromPixmapReq);
|
||||
xDRI3BuffersFromPixmapReply rep = {
|
||||
.type = X_Reply,
|
||||
.sequenceNumber = client->sequence,
|
||||
};
|
||||
int rc;
|
||||
int fds[4];
|
||||
int num_fds;
|
||||
|
@ -545,13 +539,25 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
|
|||
if (num_fds == 0)
|
||||
return BadPixmap;
|
||||
|
||||
rep.nfd = num_fds;
|
||||
rep.length = bytes_to_int32(num_fds * 2 * sizeof(CARD32));
|
||||
rep.width = pixmap->drawable.width;
|
||||
rep.height = pixmap->drawable.height;
|
||||
rep.depth = pixmap->drawable.depth;
|
||||
rep.bpp = pixmap->drawable.bitsPerPixel;
|
||||
rep.modifier = modifier;
|
||||
for (i = 0; i < num_fds; i++) {
|
||||
if (WriteFdToClient(client, fds[i], TRUE) < 0) {
|
||||
while (i--)
|
||||
close(fds[i]);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
|
||||
xDRI3BuffersFromPixmapReply rep = {
|
||||
.type = X_Reply,
|
||||
.sequenceNumber = client->sequence,
|
||||
.nfd = num_fds,
|
||||
.length = bytes_to_int32(num_fds * 2 * sizeof(CARD32)),
|
||||
.width = pixmap->drawable.width,
|
||||
.height = pixmap->drawable.height,
|
||||
.depth = pixmap->drawable.depth,
|
||||
.bpp = pixmap->drawable.bitsPerPixel,
|
||||
.modifier = modifier,
|
||||
};
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&rep.sequenceNumber);
|
||||
|
@ -565,14 +571,6 @@ proc_dri3_buffers_from_pixmap(ClientPtr client)
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < num_fds; i++) {
|
||||
if (WriteFdToClient(client, fds[i], TRUE) < 0) {
|
||||
while (i--)
|
||||
close(fds[i]);
|
||||
return BadAlloc;
|
||||
}
|
||||
}
|
||||
|
||||
WriteToClient(client, sizeof(rep), &rep);
|
||||
WriteToClient(client, num_fds * sizeof(CARD32), strides);
|
||||
WriteToClient(client, num_fds * sizeof(CARD32), offsets);
|
||||
|
|
Loading…
Reference in New Issue