diff options
-rw-r--r-- | hw/xfree86/dixmods/extmod/xf86dga2.c | 141 | ||||
-rw-r--r-- | hw/xfree86/dixmods/extmod/xf86vmode.c | 211 | ||||
-rw-r--r-- | hw/xfree86/dri/xf86dri.c | 112 | ||||
-rw-r--r-- | hw/xfree86/dri2/dri2ext.c | 99 |
4 files changed, 302 insertions, 261 deletions
diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c index 347282c97..9b7ec148b 100644 --- a/hw/xfree86/dixmods/extmod/xf86dga2.c +++ b/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -75,14 +75,15 @@ XDGAResetProc(ExtensionEntry * extEntry) static int ProcXDGAQueryVersion(ClientPtr client) { - xXDGAQueryVersionReply rep; + xXDGAQueryVersionReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .majorVersion = SERVER_XDGA_MAJOR_VERSION, + .minorVersion = SERVER_XDGA_MINOR_VERSION + }; REQUEST_SIZE_MATCH(xXDGAQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = SERVER_XDGA_MAJOR_VERSION; - rep.minorVersion = SERVER_XDGA_MINOR_VERSION; WriteToClient(client, sizeof(xXDGAQueryVersionReply), &rep); return Success; @@ -92,7 +93,11 @@ static int ProcXDGAOpenFramebuffer(ClientPtr client) { REQUEST(xXDGAOpenFramebufferReq); - xXDGAOpenFramebufferReply rep; + xXDGAOpenFramebufferReply rep = { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence + }; char *deviceName; int nameSize; @@ -104,10 +109,6 @@ ProcXDGAOpenFramebuffer(ClientPtr client) if (!DGAAvailable(stuff->screen)) return DGAErrorBase + XF86DGANoDirectVideoMode; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - if (!DGAOpenFramebuffer(stuff->screen, &deviceName, (unsigned char **) (&rep.mem1), (int *) &rep.size, (int *) &rep.offset, @@ -149,7 +150,12 @@ ProcXDGAQueryModes(ClientPtr client) int i, num, size; REQUEST(xXDGAQueryModesReq); - xXDGAQueryModesReply rep; + xXDGAQueryModesReply rep = { + .type = X_Reply, + .length = 0, + .number = 0, + .sequenceNumber = client->sequence + }; xXDGAModeInfo info; XDGAModePtr mode; @@ -158,11 +164,6 @@ ProcXDGAQueryModes(ClientPtr client) if (stuff->screen >= screenInfo.numScreens) return BadValue; - rep.type = X_Reply; - rep.length = 0; - rep.number = 0; - rep.sequenceNumber = client->sequence; - if (!DGAAvailable(stuff->screen)) { rep.number = 0; rep.length = 0; @@ -262,7 +263,13 @@ static int ProcXDGASetMode(ClientPtr client) { REQUEST(xXDGASetModeReq); - xXDGASetModeReply rep; + xXDGASetModeReply rep = { + .type = X_Reply, + .length = 0, + .offset = 0, + .flags = 0, + .sequenceNumber = client->sequence + }; XDGAModeRec mode; xXDGAModeInfo info; PixmapPtr pPix; @@ -275,12 +282,6 @@ ProcXDGASetMode(ClientPtr client) return BadValue; owner = DGA_GETCLIENT(stuff->screen); - rep.type = X_Reply; - rep.length = 0; - rep.offset = 0; - rep.flags = 0; - rep.sequenceNumber = client->sequence; - if (!DGAAvailable(stuff->screen)) return DGAErrorBase + XF86DGANoDirectVideoMode; @@ -482,7 +483,11 @@ static int ProcXDGAGetViewportStatus(ClientPtr client) { REQUEST(xXDGAGetViewportStatusReq); - xXDGAGetViewportStatusReply rep; + xXDGAGetViewportStatusReply rep = { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence + }; REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq); @@ -492,10 +497,6 @@ ProcXDGAGetViewportStatus(ClientPtr client) if (DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.status = DGAGetViewportStatus(stuff->screen); WriteToClient(client, sizeof(xXDGAGetViewportStatusReply), &rep); @@ -506,7 +507,11 @@ static int ProcXDGASync(ClientPtr client) { REQUEST(xXDGASyncReq); - xXDGASyncReply rep; + xXDGASyncReply rep = { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence + }; REQUEST_SIZE_MATCH(xXDGASyncReq); @@ -516,10 +521,6 @@ ProcXDGASync(ClientPtr client) if (DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - DGASync(stuff->screen); WriteToClient(client, sizeof(xXDGASyncReply), &rep); @@ -562,18 +563,19 @@ ProcXDGAChangePixmapMode(ClientPtr client) if (DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - x = stuff->x; y = stuff->y; if (!DGAChangePixmapMode(stuff->screen, &x, &y, stuff->flags)) return BadMatch; - rep.x = x; - rep.y = y; + rep = (xXDGAChangePixmapModeReply) { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence, + .x = x, + .y = y + }; WriteToClient(client, sizeof(xXDGAChangePixmapModeReply), &rep); return Success; @@ -616,7 +618,11 @@ static int ProcXF86DGAGetVideoLL(ClientPtr client) { REQUEST(xXF86DGAGetVideoLLReq); - xXF86DGAGetVideoLLReply rep; + xXF86DGAGetVideoLLReply rep = { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence + }; XDGAModeRec mode; int num, offset, flags; char *name; @@ -626,10 +632,6 @@ ProcXF86DGAGetVideoLL(ClientPtr client) if (stuff->screen >= screenInfo.numScreens) return BadValue; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - if (!DGAAvailable(stuff->screen)) return DGAErrorBase + XF86DGANoDirectVideoMode; @@ -726,10 +728,6 @@ ProcXF86DGAGetViewPortSize(ClientPtr client) if (stuff->screen >= screenInfo.numScreens) return BadValue; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - if (!DGAAvailable(stuff->screen)) return DGAErrorBase + XF86DGANoDirectVideoMode; @@ -738,8 +736,13 @@ ProcXF86DGAGetViewPortSize(ClientPtr client) DGAGetModeInfo(stuff->screen, &mode, num); - rep.width = mode.viewportWidth; - rep.height = mode.viewportHeight; + rep = (xXF86DGAGetViewPortSizeReply) { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence, + .width = mode.viewportWidth, + .height = mode.viewportHeight + }; WriteToClient(client, SIZEOF(xXF86DGAGetViewPortSizeReply), &rep); return Success; @@ -775,18 +778,18 @@ static int ProcXF86DGAGetVidPage(ClientPtr client) { REQUEST(xXF86DGAGetVidPageReq); - xXF86DGAGetVidPageReply rep; + xXF86DGAGetVidPageReply rep = { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence, + .vpage = 0 /* silently fail */ + }; REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq); if (stuff->screen >= screenInfo.numScreens) return BadValue; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.vpage = 0; /* silently fail */ - WriteToClient(client, SIZEOF(xXF86DGAGetVidPageReply), &rep); return Success; } @@ -840,18 +843,18 @@ static int ProcXF86DGAQueryDirectVideo(ClientPtr client) { REQUEST(xXF86DGAQueryDirectVideoReq); - xXF86DGAQueryDirectVideoReply rep; + xXF86DGAQueryDirectVideoReply rep = { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence, + .flags = 0 + }; REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq); if (stuff->screen >= screenInfo.numScreens) return BadValue; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.flags = 0; - if (DGAAvailable(stuff->screen)) rep.flags = XF86DGADirectPresent; @@ -863,7 +866,12 @@ static int ProcXF86DGAViewPortChanged(ClientPtr client) { REQUEST(xXF86DGAViewPortChangedReq); - xXF86DGAViewPortChangedReply rep; + xXF86DGAViewPortChangedReply rep = { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence, + .result = 1 + }; REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq); @@ -876,11 +884,6 @@ ProcXF86DGAViewPortChanged(ClientPtr client) if (!DGAActive(stuff->screen)) return DGAErrorBase + XF86DGADirectNotActivated; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.result = 1; - WriteToClient(client, SIZEOF(xXF86DGAViewPortChangedReply), &rep); return Success; } diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c index 0435cb6d2..455ff34ad 100644 --- a/hw/xfree86/dixmods/extmod/xf86vmode.c +++ b/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -282,16 +282,18 @@ SXF86VidModeNotifyEvent(xXF86VidModeNotifyEvent * from, static int ProcXF86VidModeQueryVersion(ClientPtr client) { - xXF86VidModeQueryVersionReply rep; + xXF86VidModeQueryVersionReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION, + .minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION + }; DEBUG_P("XF86VidModeQueryVersion"); REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = SERVER_XF86VIDMODE_MAJOR_VERSION; - rep.minorVersion = SERVER_XF86VIDMODE_MINOR_VERSION; + if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -306,8 +308,10 @@ static int ProcXF86VidModeGetModeLine(ClientPtr client) { REQUEST(xXF86VidModeGetModeLineReq); - xXF86VidModeGetModeLineReply rep; - xXF86OldVidModeGetModeLineReply oldrep; + xXF86VidModeGetModeLineReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence + }; pointer mode; int dotClock; int ver; @@ -316,7 +320,7 @@ ProcXF86VidModeGetModeLine(ClientPtr client) ver = ClientMajorVersion(client); REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq); - rep.type = X_Reply; + if (ver < 2) { rep.length = bytes_to_int32(SIZEOF(xXF86OldVidModeGetModeLineReply) - SIZEOF(xGenericReply)); @@ -325,7 +329,6 @@ ProcXF86VidModeGetModeLine(ClientPtr client) rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xGenericReply)); } - rep.sequenceNumber = client->sequence; if (stuff->screen >= screenInfo.numScreens) return BadValue; @@ -379,20 +382,22 @@ ProcXF86VidModeGetModeLine(ClientPtr client) swapl(&rep.privsize); } if (ver < 2) { - oldrep.type = rep.type; - oldrep.sequenceNumber = rep.sequenceNumber; - oldrep.length = rep.length; - oldrep.dotclock = rep.dotclock; - oldrep.hdisplay = rep.hdisplay; - oldrep.hsyncstart = rep.hsyncstart; - oldrep.hsyncend = rep.hsyncend; - oldrep.htotal = rep.htotal; - oldrep.vdisplay = rep.vdisplay; - oldrep.vsyncstart = rep.vsyncstart; - oldrep.vsyncend = rep.vsyncend; - oldrep.vtotal = rep.vtotal; - oldrep.flags = rep.flags; - oldrep.privsize = rep.privsize; + xXF86OldVidModeGetModeLineReply oldrep = { + .type = rep.type, + .sequenceNumber = rep.sequenceNumber, + .length = rep.length, + .dotclock = rep.dotclock, + .hdisplay = rep.hdisplay, + .hsyncstart = rep.hsyncstart, + .hsyncend = rep.hsyncend, + .htotal = rep.htotal, + .vdisplay = rep.vdisplay, + .vsyncstart = rep.vsyncstart, + .vsyncend = rep.vsyncend, + .vtotal = rep.vtotal, + .flags = rep.flags, + .privsize = rep.privsize + }; WriteToClient(client, sizeof(xXF86OldVidModeGetModeLineReply), &oldrep); } else { @@ -406,8 +411,6 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client) { REQUEST(xXF86VidModeGetAllModeLinesReq); xXF86VidModeGetAllModeLinesReply rep; - xXF86VidModeModeInfo mdinf; - xXF86OldVidModeModeInfo oldmdinf; pointer mode; int modecount, dotClock; int ver; @@ -428,16 +431,18 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client) if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock)) return BadValue; - rep.type = X_Reply; - rep.length = SIZEOF(xXF86VidModeGetAllModeLinesReply) - - SIZEOF(xGenericReply); + rep = (xXF86VidModeGetAllModeLinesReply) { + .type = X_Reply, + .length = SIZEOF(xXF86VidModeGetAllModeLinesReply) - + SIZEOF(xGenericReply), + .sequenceNumber = client->sequence, + .modecount = modecount + }; if (ver < 2) rep.length += modecount * sizeof(xXF86OldVidModeModeInfo); else rep.length += modecount * sizeof(xXF86VidModeModeInfo); rep.length >>= 2; - rep.sequenceNumber = client->sequence; - rep.modecount = modecount; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -446,18 +451,20 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client) WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), &rep); do { - mdinf.dotclock = dotClock; - mdinf.hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY); - mdinf.hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART); - mdinf.hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND); - mdinf.htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL); - mdinf.hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW); - mdinf.vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY); - mdinf.vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART); - mdinf.vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND); - mdinf.vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL); - mdinf.flags = VidModeGetModeValue(mode, VIDMODE_FLAGS); - mdinf.privsize = 0; + xXF86VidModeModeInfo mdinf = { + .dotclock = dotClock, + .hdisplay = VidModeGetModeValue(mode, VIDMODE_H_DISPLAY), + .hsyncstart = VidModeGetModeValue(mode, VIDMODE_H_SYNCSTART), + .hsyncend = VidModeGetModeValue(mode, VIDMODE_H_SYNCEND), + .htotal = VidModeGetModeValue(mode, VIDMODE_H_TOTAL), + .hskew = VidModeGetModeValue(mode, VIDMODE_H_SKEW), + .vdisplay = VidModeGetModeValue(mode, VIDMODE_V_DISPLAY), + .vsyncstart = VidModeGetModeValue(mode, VIDMODE_V_SYNCSTART), + .vsyncend = VidModeGetModeValue(mode, VIDMODE_V_SYNCEND), + .vtotal = VidModeGetModeValue(mode, VIDMODE_V_TOTAL), + .flags = VidModeGetModeValue(mode, VIDMODE_FLAGS), + .privsize = 0 + }; if (client->swapped) { swapl(&mdinf.dotclock); swaps(&mdinf.hdisplay); @@ -473,17 +480,19 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client) swapl(&mdinf.privsize); } if (ver < 2) { - oldmdinf.dotclock = mdinf.dotclock; - oldmdinf.hdisplay = mdinf.hdisplay; - oldmdinf.hsyncstart = mdinf.hsyncstart; - oldmdinf.hsyncend = mdinf.hsyncend; - oldmdinf.htotal = mdinf.htotal; - oldmdinf.vdisplay = mdinf.vdisplay; - oldmdinf.vsyncstart = mdinf.vsyncstart; - oldmdinf.vsyncend = mdinf.vsyncend; - oldmdinf.vtotal = mdinf.vtotal; - oldmdinf.flags = mdinf.flags; - oldmdinf.privsize = mdinf.privsize; + xXF86OldVidModeModeInfo oldmdinf = { + .dotclock = mdinf.dotclock, + .hdisplay = mdinf.hdisplay, + .hsyncstart = mdinf.hsyncstart, + .hsyncend = mdinf.hsyncend, + .htotal = mdinf.htotal, + .vdisplay = mdinf.vdisplay, + .vsyncstart = mdinf.vsyncstart, + .vsyncend = mdinf.vsyncend, + .vtotal = mdinf.vtotal, + .flags = mdinf.flags, + .privsize = mdinf.privsize + }; WriteToClient(client, sizeof(xXF86OldVidModeModeInfo), &oldmdinf); } else { @@ -1027,11 +1036,13 @@ ProcXF86VidModeValidateModeLine(ClientPtr client) status_reply: free(modetmp); - rep.type = X_Reply; - rep.length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply) - - SIZEOF(xGenericReply)); - rep.sequenceNumber = client->sequence; - rep.status = status; + rep = (xXF86VidModeValidateModeLineReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply) + - SIZEOF(xGenericReply)), + .status = status + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -1186,7 +1197,10 @@ static int ProcXF86VidModeGetMonitor(ClientPtr client) { REQUEST(xXF86VidModeGetMonitorReq); - xXF86VidModeGetMonitorReply rep; + xXF86VidModeGetMonitorReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence + }; CARD32 *hsyncdata, *vsyncdata; int i, nHsync, nVrefresh; pointer monitor; @@ -1204,7 +1218,6 @@ ProcXF86VidModeGetMonitor(ClientPtr client) nHsync = VidModeGetMonitorValue(monitor, VIDMODE_MON_NHSYNC, 0).i; nVrefresh = VidModeGetMonitorValue(monitor, VIDMODE_MON_NVREFRESH, 0).i; - rep.type = X_Reply; if ((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, 0)).ptr) rep.vendorLength = strlen((char *) (VidModeGetMonitorValue(monitor, VIDMODE_MON_VENDOR, @@ -1223,7 +1236,6 @@ ProcXF86VidModeGetMonitor(ClientPtr client) nVrefresh) * sizeof(CARD32) + pad_to_int32(rep.vendorLength) + pad_to_int32(rep.modelLength)); - rep.sequenceNumber = client->sequence; rep.nhsync = nHsync; rep.nvsync = nVrefresh; hsyncdata = malloc(nHsync * sizeof(CARD32)); @@ -1289,13 +1301,15 @@ ProcXF86VidModeGetViewPort(ClientPtr client) if (stuff->screen >= screenInfo.numScreens) return BadValue; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - VidModeGetViewPort(stuff->screen, &x, &y); - rep.x = x; - rep.y = y; + + rep = (xXF86VidModeGetViewPortReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .x = x, + .y = y + }; if (client->swapped) { swaps(&rep.sequenceNumber); @@ -1345,13 +1359,15 @@ ProcXF86VidModeGetDotClocks(ClientPtr client) numClocks = VidModeGetNumOfClocks(stuff->screen, &ClockProg); - rep.type = X_Reply; - rep.length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply) - - SIZEOF(xGenericReply) + numClocks); - rep.sequenceNumber = client->sequence; - rep.clocks = numClocks; - rep.maxclocks = MAXCLOCKS; - rep.flags = 0; + rep = (xXF86VidModeGetDotClocksReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(SIZEOF(xXF86VidModeGetDotClocksReply) + - SIZEOF(xGenericReply) + numClocks), + .clocks = numClocks, + .maxclocks = MAXCLOCKS, + .flags = 0 + }; if (!ClockProg) { Clocks = calloc(numClocks, sizeof(int)); @@ -1423,14 +1439,16 @@ ProcXF86VidModeGetGamma(ClientPtr client) if (stuff->screen >= screenInfo.numScreens) return BadValue; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; if (!VidModeGetGamma(stuff->screen, &red, &green, &blue)) return BadValue; - rep.red = (CARD32) (red * 10000.); - rep.green = (CARD32) (green * 10000.); - rep.blue = (CARD32) (blue * 10000.); + rep = (xXF86VidModeGetGammaReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .red = (CARD32) (red * 10000.), + .green = (CARD32) (green * 10000.), + .blue = (CARD32) (blue * 10000.) + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -1502,10 +1520,12 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client) return BadValue; } } - rep.type = X_Reply; - rep.length = (length >> 1) * 3; - rep.sequenceNumber = client->sequence; - rep.size = stuff->size; + rep = (xXF86VidModeGetGammaRampReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = (length >> 1) * 3, + .size = stuff->size + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -1534,10 +1554,12 @@ ProcXF86VidModeGetGammaRampSize(ClientPtr client) if (stuff->screen >= screenInfo.numScreens) return BadValue; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.size = VidModeGetGammaRampSize(stuff->screen); + rep = (xXF86VidModeGetGammaRampSizeReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .size = VidModeGetGammaRampSize(stuff->screen) + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -1551,7 +1573,12 @@ ProcXF86VidModeGetGammaRampSize(ClientPtr client) static int ProcXF86VidModeGetPermissions(ClientPtr client) { - xXF86VidModeGetPermissionsReply rep; + xXF86VidModeGetPermissionsReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .permissions = XF86VM_READ_PERMISSION + }; REQUEST(xXF86VidModeGetPermissionsReq); @@ -1560,10 +1587,6 @@ ProcXF86VidModeGetPermissions(ClientPtr client) if (stuff->screen >= screenInfo.numScreens) return BadValue; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.permissions = XF86VM_READ_PERMISSION; if (xf86GetVidModeEnabled() && (xf86GetVidModeAllowNonLocal() || LocalClient(client))) { rep.permissions |= XF86VM_WRITE_PERMISSION; diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index 43504b7fe..310bb5e4e 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -78,15 +78,16 @@ XF86DRIResetProc(ExtensionEntry * extEntry) static int ProcXF86DRIQueryVersion(register ClientPtr client) { - xXF86DRIQueryVersionReply rep; + xXF86DRIQueryVersionReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .majorVersion = SERVER_XF86DRI_MAJOR_VERSION, + .minorVersion = SERVER_XF86DRI_MINOR_VERSION, + .patchVersion = SERVER_XF86DRI_PATCH_VERSION + }; REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = SERVER_XF86DRI_MAJOR_VERSION; - rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION; - rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -111,18 +112,20 @@ ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client) return BadValue; } - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - if (!DRIQueryDirectRenderingCapable(screenInfo.screens[stuff->screen], &isCapable)) { return BadValue; } - rep.isCapable = isCapable; if (!LocalClient(client) || client->swapped) - rep.isCapable = 0; + isCapable = 0; + + rep = (xXF86DRIQueryDirectRenderingCapableReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .isCapable = isCapable + }; if (client->swapped) { swaps(&rep.sequenceNumber); @@ -158,20 +161,21 @@ ProcXF86DRIOpenConnection(register ClientPtr client) if (busIdString) busIdStringLength = strlen(busIdString); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.busIdStringLength = busIdStringLength; - rep.length = - bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - - SIZEOF(xGenericReply) + - pad_to_int32(rep.busIdStringLength)); + rep = (xXF86DRIOpenConnectionReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - + SIZEOF(xGenericReply) + + pad_to_int32(busIdStringLength)), + .busIdStringLength = busIdStringLength, - rep.hSAREALow = (CARD32) (hSAREA & 0xffffffff); + .hSAREALow = (CARD32) (hSAREA & 0xffffffff), #if defined(LONG64) && !defined(__linux__) - rep.hSAREAHigh = (CARD32) (hSAREA >> 32); + .hSAREAHigh = (CARD32) (hSAREA >> 32), #else - rep.hSAREAHigh = 0; + .hSAREAHigh = 0 #endif + }; WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep); if (busIdStringLength) @@ -182,7 +186,12 @@ ProcXF86DRIOpenConnection(register ClientPtr client) static int ProcXF86DRIAuthConnection(register ClientPtr client) { - xXF86DRIAuthConnectionReply rep; + xXF86DRIAuthConnectionReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .authenticated = 1 + }; REQUEST(xXF86DRIAuthConnectionReq); REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq); @@ -191,11 +200,6 @@ ProcXF86DRIAuthConnection(register ClientPtr client) return BadValue; } - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.authenticated = 1; - if (!DRIAuthConnection(screenInfo.screens[stuff->screen], stuff->magic)) { ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic); rep.authenticated = 0; @@ -222,7 +226,11 @@ ProcXF86DRICloseConnection(register ClientPtr client) static int ProcXF86DRIGetClientDriverName(register ClientPtr client) { - xXF86DRIGetClientDriverNameReply rep; + xXF86DRIGetClientDriverNameReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .clientDriverNameLength = 0 + }; char *clientDriverName; REQUEST(xXF86DRIGetClientDriverNameReq); @@ -238,9 +246,6 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client) (int *) &rep.ddxDriverPatchVersion, &clientDriverName); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.clientDriverNameLength = 0; if (clientDriverName) rep.clientDriverNameLength = strlen(clientDriverName); rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) - @@ -256,7 +261,11 @@ ProcXF86DRIGetClientDriverName(register ClientPtr client) static int ProcXF86DRICreateContext(register ClientPtr client) { - xXF86DRICreateContextReply rep; + xXF86DRICreateContextReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; ScreenPtr pScreen; REQUEST(xXF86DRICreateContextReq); @@ -266,10 +275,6 @@ ProcXF86DRICreateContext(register ClientPtr client) return BadValue; } - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - pScreen = screenInfo.screens[stuff->screen]; if (!DRICreateContext(pScreen, @@ -302,7 +307,11 @@ ProcXF86DRIDestroyContext(register ClientPtr client) static int ProcXF86DRICreateDrawable(ClientPtr client) { - xXF86DRICreateDrawableReply rep; + xXF86DRICreateDrawableReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; DrawablePtr pDrawable; int rc; @@ -313,10 +322,6 @@ ProcXF86DRICreateDrawable(ClientPtr client) return BadValue; } - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, DixReadAccess); if (rc != Success) @@ -361,7 +366,11 @@ ProcXF86DRIDestroyDrawable(register ClientPtr client) static int ProcXF86DRIGetDrawableInfo(register ClientPtr client) { - xXF86DRIGetDrawableInfoReply rep; + xXF86DRIGetDrawableInfoReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; DrawablePtr pDrawable; int X, Y, W, H; drm_clip_rect_t *pClipRects, *pClippedRects; @@ -375,10 +384,6 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) return BadValue; } - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, DixReadAccess); if (rc != Success) @@ -466,7 +471,11 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client) static int ProcXF86DRIGetDeviceInfo(register ClientPtr client) { - xXF86DRIGetDeviceInfoReply rep; + xXF86DRIGetDeviceInfoReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; drm_handle_t hFrameBuffer; void *pDevPrivate; @@ -477,10 +486,6 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client) return BadValue; } - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - if (!DRIGetDeviceInfo(screenInfo.screens[stuff->screen], &hFrameBuffer, (int *) &rep.framebufferOrigin, @@ -497,7 +502,6 @@ ProcXF86DRIGetDeviceInfo(register ClientPtr client) rep.hFrameBufferHigh = 0; #endif - rep.length = 0; if (rep.devPrivateSize) { rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) - SIZEOF(xGenericReply) + diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c index 3bc3ea74e..a6be4c269 100644 --- a/hw/xfree86/dri2/dri2ext.c +++ b/hw/xfree86/dri2/dri2ext.c @@ -71,17 +71,18 @@ static int ProcDRI2QueryVersion(ClientPtr client) { REQUEST(xDRI2QueryVersionReq); - xDRI2QueryVersionReply rep; + xDRI2QueryVersionReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .majorVersion = dri2_major, + .minorVersion = dri2_minor + }; if (client->swapped) swaps(&stuff->length); REQUEST_SIZE_MATCH(xDRI2QueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = dri2_major; - rep.minorVersion = dri2_minor; if (client->swapped) { swaps(&rep.sequenceNumber); @@ -99,7 +100,13 @@ static int ProcDRI2Connect(ClientPtr client) { REQUEST(xDRI2ConnectReq); - xDRI2ConnectReply rep; + xDRI2ConnectReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .driverNameLength = 0, + .deviceNameLength = 0 + }; DrawablePtr pDraw; int fd, status; const char *driverName; @@ -110,12 +117,6 @@ ProcDRI2Connect(ClientPtr client) &pDraw, &status)) return status; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.driverNameLength = 0; - rep.deviceNameLength = 0; - if (!DRI2Connect(client, pDraw->pScreen, stuff->driverType, &fd, &driverName, &deviceName)) goto fail; @@ -146,10 +147,12 @@ ProcDRI2Authenticate(ClientPtr client) &pDraw, &status)) return status; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.authenticated = DRI2Authenticate(client, pDraw->pScreen, stuff->magic); + rep = (xDRI2AuthenticateReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .authenticated = DRI2Authenticate(client, pDraw->pScreen, stuff->magic) + }; WriteToClient(client, sizeof(xDRI2AuthenticateReply), &rep); return Success; @@ -225,12 +228,14 @@ send_buffers_reply(ClientPtr client, DrawablePtr pDrawable, } } - rep.type = X_Reply; - rep.length = (count - skip) * sizeof(xDRI2Buffer) / 4; - rep.sequenceNumber = client->sequence; - rep.width = width; - rep.height = height; - rep.count = count - skip; + rep = (xDRI2GetBuffersReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = (count - skip) * sizeof(xDRI2Buffer) / 4, + .width = width, + .height = height, + .count = count - skip + }; WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep); for (i = 0; i < count; i++) { @@ -330,9 +335,11 @@ ProcDRI2CopyRegion(ClientPtr client) * that yet. */ - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; + rep = (xDRI2CopyRegionReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; WriteToClient(client, sizeof(xDRI2CopyRegionReply), &rep); @@ -375,7 +382,11 @@ static int ProcDRI2SwapBuffers(ClientPtr client) { REQUEST(xDRI2SwapBuffersReq); - xDRI2SwapBuffersReply rep; + xDRI2SwapBuffersReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; DrawablePtr pDrawable; CARD64 target_msc, divisor, remainder, swap_target; int status; @@ -402,9 +413,6 @@ ProcDRI2SwapBuffers(ClientPtr client) if (status != Success) return BadDrawable; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; load_swap_reply(&rep, swap_target); WriteToClient(client, sizeof(xDRI2SwapBuffersReply), &rep); @@ -427,7 +435,11 @@ static int ProcDRI2GetMSC(ClientPtr client) { REQUEST(xDRI2GetMSCReq); - xDRI2MSCReply rep; + xDRI2MSCReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; DrawablePtr pDrawable; CARD64 ust, msc, sbc; int status; @@ -442,9 +454,6 @@ ProcDRI2GetMSC(ClientPtr client) if (status != Success) return status; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; load_msc_reply(&rep, ust, msc, sbc); WriteToClient(client, sizeof(xDRI2MSCReply), &rep); @@ -482,11 +491,12 @@ ProcDRI2WaitMSC(ClientPtr client) int ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust, CARD64 msc, CARD64 sbc) { - xDRI2MSCReply rep; + xDRI2MSCReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; load_msc_reply(&rep, ust, msc, sbc); WriteToClient(client, sizeof(xDRI2MSCReply), &rep); @@ -614,7 +624,13 @@ static int SProcDRI2Connect(ClientPtr client) { REQUEST(xDRI2ConnectReq); - xDRI2ConnectReply rep; + xDRI2ConnectReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .driverNameLength = 0, + .deviceNameLength = 0 + }; /* If the client is swapped, it's not local. Talk to the hand. */ @@ -622,12 +638,7 @@ SProcDRI2Connect(ClientPtr client) if (sizeof(*stuff) / 4 != client->req_len) return BadLength; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; swaps(&rep.sequenceNumber); - rep.length = 0; - rep.driverNameLength = 0; - rep.deviceNameLength = 0; WriteToClient(client, sizeof(xDRI2ConnectReply), &rep); |