diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index acf68509e..911503f47 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -81,22 +81,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 @@ -121,20 +114,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 @@ -160,8 +143,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)), @@ -173,9 +154,7 @@ ProcXF86DRIOpenConnection(register ClientPtr client) #endif }; - WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep); - if (busIdStringLength) - WriteToClient(client, busIdStringLength, busIdString); + REPLY_SEND_EXTRA(busIdString, busIdStringLength); return Success; } @@ -185,8 +164,6 @@ ProcXF86DRIAuthConnection(register ClientPtr client) REQUEST_HEAD_STRUCT(xXF86DRIAuthConnectionReq); xXF86DRIAuthConnectionReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, .authenticated = 1 }; @@ -199,8 +176,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 @@ -223,10 +200,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) { @@ -246,9 +220,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; } @@ -257,10 +229,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) { @@ -276,8 +245,7 @@ ProcXF86DRICreateContext(register ClientPtr client) return BadValue; } - WriteToClient(client, sizeof(xXF86DRICreateContextReply), &rep); - return Success; + REPLY_SEND_RET_SUCCESS(); } static int @@ -302,10 +270,7 @@ ProcXF86DRICreateDrawable(ClientPtr client) { REQUEST_HEAD_STRUCT(xXF86DRICreateDrawableReq); - xXF86DRICreateDrawableReply rep = { - .type = X_Reply, - .sequenceNumber = client->sequence, - }; + xXF86DRICreateDrawableReply rep = { 0 }; DrawablePtr pDrawable; int rc; @@ -324,8 +289,7 @@ ProcXF86DRICreateDrawable(ClientPtr client) return BadValue; } - WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), &rep); - return Success; + REPLY_SEND_RET_SUCCESS(); } static int @@ -359,10 +323,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; @@ -399,14 +360,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) { @@ -428,27 +385,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; } @@ -457,12 +398,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; @@ -483,16 +421,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; }