dri: use static struct init on declaration & drop useless assignments

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:
Enrico Weigelt, metux IT consult 2024-07-18 18:37:08 +02:00
parent bbfdb50b5c
commit c704eb884a

View File

@ -80,7 +80,6 @@ ProcXF86DRIQueryVersion(register ClientPtr client)
xXF86DRIQueryVersionReply rep = { xXF86DRIQueryVersionReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_XF86DRI_MAJOR_VERSION, .majorVersion = SERVER_XF86DRI_MAJOR_VERSION,
.minorVersion = SERVER_XF86DRI_MINOR_VERSION, .minorVersion = SERVER_XF86DRI_MINOR_VERSION,
.patchVersion = SERVER_XF86DRI_PATCH_VERSION .patchVersion = SERVER_XF86DRI_PATCH_VERSION
@ -101,7 +100,6 @@ ProcXF86DRIQueryVersion(register ClientPtr client)
static int static int
ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client) ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
{ {
xXF86DRIQueryDirectRenderingCapableReply rep;
Bool isCapable; Bool isCapable;
REQUEST(xXF86DRIQueryDirectRenderingCapableReq); REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
@ -119,10 +117,9 @@ ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
if (!client->local || client->swapped) if (!client->local || client->swapped)
isCapable = 0; isCapable = 0;
rep = (xXF86DRIQueryDirectRenderingCapableReply) { xXF86DRIQueryDirectRenderingCapableReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.isCapable = isCapable .isCapable = isCapable
}; };
@ -140,7 +137,6 @@ ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
static int static int
ProcXF86DRIOpenConnection(register ClientPtr client) ProcXF86DRIOpenConnection(register ClientPtr client)
{ {
xXF86DRIOpenConnectionReply rep;
drm_handle_t hSAREA; drm_handle_t hSAREA;
char *busIdString; char *busIdString;
CARD32 busIdStringLength = 0; CARD32 busIdStringLength = 0;
@ -160,7 +156,7 @@ ProcXF86DRIOpenConnection(register ClientPtr client)
if (busIdString) if (busIdString)
busIdStringLength = strlen(busIdString); busIdStringLength = strlen(busIdString);
rep = (xXF86DRIOpenConnectionReply) { xXF86DRIOpenConnectionReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - .length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) -
@ -171,8 +167,6 @@ ProcXF86DRIOpenConnection(register ClientPtr client)
.hSAREALow = (CARD32) (hSAREA & 0xffffffff), .hSAREALow = (CARD32) (hSAREA & 0xffffffff),
#if defined(LONG64) && !defined(__linux__) #if defined(LONG64) && !defined(__linux__)
.hSAREAHigh = (CARD32) (hSAREA >> 32), .hSAREAHigh = (CARD32) (hSAREA >> 32),
#else
.hSAREAHigh = 0
#endif #endif
}; };
@ -188,7 +182,6 @@ ProcXF86DRIAuthConnection(register ClientPtr client)
xXF86DRIAuthConnectionReply rep = { xXF86DRIAuthConnectionReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.authenticated = 1 .authenticated = 1
}; };
@ -228,7 +221,6 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client)
xXF86DRIGetClientDriverNameReply rep = { xXF86DRIGetClientDriverNameReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.clientDriverNameLength = 0
}; };
char *clientDriverName; char *clientDriverName;
@ -263,7 +255,6 @@ ProcXF86DRICreateContext(register ClientPtr client)
xXF86DRICreateContextReply rep = { xXF86DRICreateContextReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0
}; };
ScreenPtr pScreen; ScreenPtr pScreen;
@ -309,7 +300,6 @@ ProcXF86DRICreateDrawable(ClientPtr client)
xXF86DRICreateDrawableReply rep = { xXF86DRICreateDrawableReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0
}; };
DrawablePtr pDrawable; DrawablePtr pDrawable;
int rc; int rc;
@ -368,11 +358,10 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
xXF86DRIGetDrawableInfoReply rep = { xXF86DRIGetDrawableInfoReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0
}; };
DrawablePtr pDrawable; DrawablePtr pDrawable;
int X, Y, W, H; int X, Y, W, H;
drm_clip_rect_t *pClipRects, *pClippedRects; drm_clip_rect_t *pClipRects, *pClippedRects = NULL;
drm_clip_rect_t *pBackClipRects; drm_clip_rect_t *pBackClipRects;
int backX, backY, rc; int backX, backY, rc;
@ -416,8 +405,6 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
if (rep.numBackClipRects) if (rep.numBackClipRects)
rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects; rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
pClippedRects = pClipRects;
if (rep.numClipRects) { if (rep.numClipRects) {
/* Clip cliprects to screen dimensions (redirected windows) */ /* Clip cliprects to screen dimensions (redirected windows) */
pClippedRects = xallocarray(rep.numClipRects, sizeof(drm_clip_rect_t)); pClippedRects = xallocarray(rep.numClipRects, sizeof(drm_clip_rect_t));
@ -429,10 +416,12 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
int i, j; int i, j;
for (i = 0, j = 0; i < rep.numClipRects; i++) { for (i = 0, j = 0; i < rep.numClipRects; i++) {
pClippedRects[j].x1 = max(pClipRects[i].x1, 0); pClippedRects[j] = (drm_clip_rect_t) {
pClippedRects[j].y1 = max(pClipRects[i].y1, 0); .x1 = max(pClipRects[i].x1, 0),
pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width); .y1 = max(pClipRects[i].y1, 0),
pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height); .x2 = min(pClipRects[i].x2, pScreen->width),
.y2 = min(pClipRects[i].y2, pScreen->height),
};
if (pClippedRects[j].x1 < pClippedRects[j].x2 && if (pClippedRects[j].x1 < pClippedRects[j].x2 &&
pClippedRects[j].y1 < pClippedRects[j].y2) { pClippedRects[j].y1 < pClippedRects[j].y2) {
@ -470,7 +459,6 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client)
xXF86DRIGetDeviceInfoReply rep = { xXF86DRIGetDeviceInfoReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0
}; };
drm_handle_t hFrameBuffer; drm_handle_t hFrameBuffer;
void *pDevPrivate; void *pDevPrivate;
@ -494,8 +482,6 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client)
rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff); rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff);
#if defined(LONG64) && !defined(__linux__) #if defined(LONG64) && !defined(__linux__)
rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32); rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32);
#else
rep.hFrameBufferHigh = 0;
#endif #endif
if (rep.devPrivateSize) { if (rep.devPrivateSize) {