diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index 82306cbcbf..98a5e6dcb4 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -84,22 +84,15 @@ ProcXF86DRIQueryVersion(register ClientPtr client) REQUEST_HEAD_STRUCT(xXF86DRIQueryVersionReq); xXF86DRIQueryVersionReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .majorVersion = SERVER_XF86DRI_MAJOR_VERSION, .minorVersion = SERVER_XF86DRI_MINOR_VERSION, .patchVersion = SERVER_XF86DRI_PATCH_VERSION }; - 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; + REPLY_FIELD_CARD16(majorVersion); + REPLY_FIELD_CARD16(minorVersion); + REPLY_FIELD_CARD32(patchVersion); + REPLY_SEND_RET_SUCCESS(); } static int @@ -124,20 +117,10 @@ ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client) isCapable = 0; xXF86DRIQueryDirectRenderingCapableReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .isCapable = isCapable }; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - - WriteToClient(client, - sizeof(xXF86DRIQueryDirectRenderingCapableReply), - &rep); - return Success; + REPLY_SEND_RET_SUCCESS(); } static int @@ -163,8 +146,6 @@ ProcXF86DRIOpenConnection(register ClientPtr client) busIdStringLength = strlen(busIdString); xXF86DRIOpenConnectionReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) + pad_to_int32(busIdStringLength)), @@ -176,9 +157,7 @@ ProcXF86DRIOpenConnection(register ClientPtr client) #endif }; - WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep); - if (busIdStringLength) - WriteToClient(client, busIdStringLength, busIdString); + REPLY_SEND_EXTRA(busIdString, busIdStringLength); return Success; } @@ -188,8 +167,6 @@ ProcXF86DRIAuthConnection(register ClientPtr client) REQUEST_HEAD_STRUCT(xXF86DRIAuthConnectionReq); xXF86DRIAuthConnectionReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .authenticated = 1 }; @@ -202,8 +179,8 @@ ProcXF86DRIAuthConnection(register ClientPtr client) ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic); rep.authenticated = 0; } - WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), &rep); - return Success; + + REPLY_SEND_RET_SUCCESS(); } static int @@ -226,10 +203,7 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client) { REQUEST_HEAD_STRUCT(xXF86DRIGetClientDriverNameReq); - xXF86DRIGetClientDriverNameReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - }; + xXF86DRIGetClientDriverNameReply rep = { 0 }; char *clientDriverName; if (stuff->screen >= screenInfo.numScreens) { @@ -249,9 +223,7 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client) SIZEOF(xGenericReply) + pad_to_int32(rep.clientDriverNameLength)); - WriteToClient(client, sizeof(xXF86DRIGetClientDriverNameReply), &rep); - if (rep.clientDriverNameLength) - WriteToClient(client, rep.clientDriverNameLength, clientDriverName); + REPLY_SEND_EXTRA(clientDriverName, rep.clientDriverNameLength); return Success; } @@ -260,10 +232,7 @@ ProcXF86DRICreateContext(register ClientPtr client) { REQUEST_HEAD_STRUCT(xXF86DRICreateContextReq); - xXF86DRICreateContextReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - }; + xXF86DRICreateContextReply rep = { 0 }; ScreenPtr pScreen; if (stuff->screen >= screenInfo.numScreens) { @@ -279,8 +248,7 @@ ProcXF86DRICreateContext(register ClientPtr client) return BadValue; } - WriteToClient(client, sizeof(xXF86DRICreateContextReply), &rep); - return Success; + REPLY_SEND_RET_SUCCESS(); } static int @@ -305,10 +273,7 @@ ProcXF86DRICreateDrawable(ClientPtr client) { REQUEST_HEAD_STRUCT(xXF86DRICreateDrawableReq); - xXF86DRICreateDrawableReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - }; + xXF86DRICreateDrawableReply rep = { 0 }; DrawablePtr pDrawable; int rc; @@ -327,8 +292,7 @@ ProcXF86DRICreateDrawable(ClientPtr client) return BadValue; } - WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), &rep); - return Success; + REPLY_SEND_RET_SUCCESS(); } static int @@ -362,10 +326,7 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) { REQUEST_HEAD_STRUCT(xXF86DRIGetDrawableInfoReq); - xXF86DRIGetDrawableInfoReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - }; + xXF86DRIGetDrawableInfoReply rep = { 0 }; DrawablePtr pDrawable; int X, Y, W, H; drm_clip_rect_t *pClipRects; @@ -402,14 +363,10 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) rep.drawableY = Y; rep.drawableWidth = W; rep.drawableHeight = H; - rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply)); rep.backX = backX; rep.backY = backY; - if (rep.numBackClipRects) - rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects; - drm_clip_rect_t pClippedRects[rep.numClipRects]; if (rep.numClipRects) { @@ -431,27 +388,11 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) j++; } } - rep.numClipRects = j; - rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects; - } - - rep.length = bytes_to_int32(rep.length); - - WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), &rep); - - if (rep.numClipRects) { - WriteToClient(client, - sizeof(drm_clip_rect_t) * rep.numClipRects, - pClippedRects); - } - - if (rep.numBackClipRects) { - WriteToClient(client, - sizeof(drm_clip_rect_t) * rep.numBackClipRects, - pBackClipRects); } + REPLY_SEND_EXTRA_2(pClippedRects, sizeof(drm_clip_rect_t) * rep.numClipRects, + pBackClipRects, sizeof(drm_clip_rect_t) * rep.numBackClipRects); return Success; } @@ -460,12 +401,9 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client) { REQUEST_HEAD_STRUCT(xXF86DRIGetDeviceInfoReq); - xXF86DRIGetDeviceInfoReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - }; + xXF86DRIGetDeviceInfoReply rep = { 0 }; drm_handle_t hFrameBuffer; - void *pDevPrivate; + void *pDevPrivate = NULL; if (stuff->screen >= screenInfo.numScreens) { client->errorValue = stuff->screen; @@ -486,16 +424,7 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client) rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32); #endif - if (rep.devPrivateSize) { - rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) - - SIZEOF(xGenericReply) + - pad_to_int32(rep.devPrivateSize)); - } - - WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), &rep); - if (rep.length) { - WriteToClient(client, rep.devPrivateSize, pDevPrivate); - } + REPLY_SEND_EXTRA(pDevPrivate, rep.devPrivateSize); return Success; }