diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-07-09 19:12:43 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-07-09 19:58:30 -0700 |
commit | bd6f948c41865c2c9d3fba1000bf5f7458d3afc1 (patch) | |
tree | e2560b521406b16c9ecc87602845991d27e35073 | |
parent | a406bd07593edb69285cf2fd91a6af4a5d956817 (diff) |
Use C99 designated initializers in randr Replies
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r-- | randr/rrcrtc.c | 69 | ||||
-rw-r--r-- | randr/rrdispatch.c | 9 | ||||
-rw-r--r-- | randr/rrmode.c | 13 | ||||
-rw-r--r-- | randr/rroutput.c | 42 | ||||
-rw-r--r-- | randr/rrproperty.c | 32 | ||||
-rw-r--r-- | randr/rrscreen.c | 124 | ||||
-rw-r--r-- | randr/rrxinerama.c | 74 |
7 files changed, 204 insertions, 159 deletions
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index c91c7fdf9..138fbe16f 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -900,11 +900,13 @@ ProcRRGetCrtcInfo(ClientPtr client) mode = crtc->mode; - rep.type = X_Reply; - rep.status = RRSetConfigSuccess; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep = (xRRGetCrtcInfoReply) { + .type = X_Reply, + .status = RRSetConfigSuccess, + .sequenceNumber = client->sequence, + .length = 0, + .timestamp = pScrPriv->lastSetTime.milliseconds + }; if (pScrPriv->rrGetPanning && pScrPriv->rrGetPanning(pScreen, crtc, &panned_area, NULL, NULL) && (panned_area.x2 > panned_area.x1) && (panned_area.y2 > panned_area.y1)) @@ -1171,11 +1173,13 @@ ProcRRSetCrtcConfig(ClientPtr client) sendReply: free(outputs); - rep.type = X_Reply; - rep.status = status; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; + rep = (xRRSetCrtcConfigReply) { + .type = X_Reply, + .status = status, + .sequenceNumber = client->sequence, + .length = 0, + .newTimestamp = pScrPriv->lastSetTime.milliseconds + }; if (client->swapped) { swaps(&rep.sequenceNumber); @@ -1211,12 +1215,13 @@ ProcRRGetPanning(ClientPtr client) if (!pScrPriv) return RRErrorBase + BadRRCrtc; - memset(&rep, 0, sizeof(rep)); - rep.type = X_Reply; - rep.status = RRSetConfigSuccess; - rep.sequenceNumber = client->sequence; - rep.length = 1; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep = (xRRGetPanningReply) { + .type = X_Reply, + .status = RRSetConfigSuccess, + .sequenceNumber = client->sequence, + .length = 1, + .timestamp = pScrPriv->lastSetTime.milliseconds + }; if (pScrPriv->rrGetPanning && pScrPriv->rrGetPanning(pScreen, crtc, &total, &tracking, border)) { @@ -1310,11 +1315,13 @@ ProcRRSetPanning(ClientPtr client) status = RRSetConfigSuccess; sendReply: - rep.type = X_Reply; - rep.status = status; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; + rep = (xRRSetPanningReply) { + .type = X_Reply, + .status = status, + .sequenceNumber = client->sequence, + .length = 0, + .newTimestamp = pScrPriv->lastSetTime.milliseconds + }; if (client->swapped) { swaps(&rep.sequenceNumber); @@ -1339,10 +1346,12 @@ ProcRRGetCrtcGammaSize(ClientPtr client) if (!RRCrtcGammaGet(crtc)) return RRErrorBase + BadRRCrtc; - reply.type = X_Reply; - reply.sequenceNumber = client->sequence; - reply.length = 0; - reply.size = crtc->gammaSize; + reply = (xRRGetCrtcGammaSizeReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .size = crtc->gammaSize + }; if (client->swapped) { swaps(&reply.sequenceNumber); swapl(&reply.length); @@ -1376,10 +1385,12 @@ ProcRRGetCrtcGamma(ClientPtr client) return BadAlloc; } - reply.type = X_Reply; - reply.sequenceNumber = client->sequence; - reply.length = bytes_to_int32(len); - reply.size = crtc->gammaSize; + reply = (xRRGetCrtcGammaReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(len), + .size = crtc->gammaSize + }; if (client->swapped) { swaps(&reply.sequenceNumber); swapl(&reply.length); diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c index d071787ca..7fbc9f01c 100644 --- a/randr/rrdispatch.c +++ b/randr/rrdispatch.c @@ -35,16 +35,17 @@ RRClientKnowsRates(ClientPtr pClient) static int ProcRRQueryVersion(ClientPtr client) { - xRRQueryVersionReply rep = { 0 }; + xRRQueryVersionReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; REQUEST(xRRQueryVersionReq); rrClientPriv(client); REQUEST_SIZE_MATCH(xRRQueryVersionReq); pRRClient->major_version = stuff->majorVersion; pRRClient->minor_version = stuff->minorVersion; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; if (version_compare(stuff->majorVersion, stuff->minorVersion, SERVER_RANDR_MAJOR_VERSION, diff --git a/randr/rrmode.c b/randr/rrmode.c index 7e17d7d84..56e5977b5 100644 --- a/randr/rrmode.c +++ b/randr/rrmode.c @@ -282,7 +282,7 @@ int ProcRRCreateMode(ClientPtr client) { REQUEST(xRRCreateModeReq); - xRRCreateModeReply rep = { 0 }; + xRRCreateModeReply rep; WindowPtr pWin; ScreenPtr pScreen; xRRModeInfo *modeInfo; @@ -310,11 +310,12 @@ ProcRRCreateMode(ClientPtr client) if (!mode) return error; - rep.type = X_Reply; - rep.pad0 = 0; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.mode = mode->mode.id; + rep = (xRRCreateModeReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .mode = mode->mode.id + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); diff --git a/randr/rroutput.c b/randr/rroutput.c index 3662a5a6b..093250829 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -425,22 +425,23 @@ ProcRRGetOutputInfo(ClientPtr client) pScreen = output->pScreen; pScrPriv = rrGetScrPriv(pScreen); - rep.type = X_Reply; - rep.status = RRSetConfigSuccess; - rep.sequenceNumber = client->sequence; - rep.length = bytes_to_int32(OutputInfoExtra); - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.crtc = output->crtc ? output->crtc->id : None; - rep.mmWidth = output->mmWidth; - rep.mmHeight = output->mmHeight; - rep.connection = output->connection; - rep.subpixelOrder = output->subpixelOrder; - rep.nCrtcs = output->numCrtcs; - rep.nModes = output->numModes + output->numUserModes; - rep.nPreferred = output->numPreferred; - rep.nClones = output->numClones; - rep.nameLength = output->nameLength; - + rep = (xRRGetOutputInfoReply) { + .type = X_Reply, + .status = RRSetConfigSuccess, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(OutputInfoExtra), + .timestamp = pScrPriv->lastSetTime.milliseconds, + .crtc = output->crtc ? output->crtc->id : None, + .mmWidth = output->mmWidth, + .mmHeight = output->mmHeight, + .connection = output->connection, + .subpixelOrder = output->subpixelOrder, + .nCrtcs = output->numCrtcs, + .nModes = output->numModes + output->numUserModes, + .nPreferred = output->numPreferred, + .nClones = output->numClones, + .nameLength = output->nameLength + }; extraLen = ((output->numCrtcs + output->numModes + output->numUserModes + output->numClones + bytes_to_int32(rep.nameLength)) << 2); @@ -573,10 +574,11 @@ ProcRRGetOutputPrimary(ClientPtr client) if (pScrPriv) primary = pScrPriv->primaryOutput; - memset(&rep, 0, sizeof(rep)); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.output = primary ? primary->id : None; + rep = (xRRGetOutputPrimaryReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .output = primary ? primary->id : None + }; if (client->swapped) { swaps(&rep.sequenceNumber); diff --git a/randr/rrproperty.c b/randr/rrproperty.c index b0a1cf900..7ce085c0c 100644 --- a/randr/rrproperty.c +++ b/randr/rrproperty.c @@ -394,10 +394,12 @@ ProcRRListOutputProperties(ClientPtr client) if (!(pAtoms = (Atom *) malloc(numProps * sizeof(Atom)))) return BadAlloc; - rep.type = X_Reply; - rep.length = bytes_to_int32(numProps * sizeof(Atom)); - rep.sequenceNumber = client->sequence; - rep.nAtoms = numProps; + rep = (xRRListOutputPropertiesReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(numProps * sizeof(Atom)), + .nAtoms = numProps + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -440,12 +442,16 @@ ProcRRQueryOutputProperty(ClientPtr client) if (!extra) return BadAlloc; } - rep.type = X_Reply; - rep.length = prop->num_valid; - rep.sequenceNumber = client->sequence; - rep.pending = prop->is_pending; - rep.range = prop->range; - rep.immutable = prop->immutable; + + rep = (xRRQueryOutputPropertyReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = prop->num_valid, + .pending = prop->is_pending, + .range = prop->range, + .immutable = prop->immutable + }; + if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -596,8 +602,10 @@ ProcRRGetOutputProperty(ClientPtr client) if (prop->propertyName == stuff->property) break; - reply.type = X_Reply; - reply.sequenceNumber = client->sequence; + reply = (xRRGetOutputPropertyReply) { + .type = X_Reply, + .sequenceNumber = client->sequence + }; if (!prop) { reply.nItems = 0; reply.length = 0; diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 6fd24e02d..774f8be52 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -203,10 +203,12 @@ ProcRRGetScreenSizeRange(ClientPtr client) pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); - rep.type = X_Reply; - rep.pad = 0; - rep.sequenceNumber = client->sequence; - rep.length = 0; + rep = (xRRGetScreenSizeRangeReply) { + .type = X_Reply, + .pad = 0, + .sequenceNumber = client->sequence, + .length = 0 + }; if (pScrPriv) { if (!RRGetInfo(pScreen, FALSE)) @@ -481,7 +483,6 @@ rrGetScreenResources(ClientPtr client, Bool query) pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); - rep.pad = 0; if (query && pScrPriv) if (!RRGetInfo(pScreen, query)) @@ -491,15 +492,17 @@ rrGetScreenResources(ClientPtr client, Bool query) return rrGetMultiScreenResources(client, query, pScreen); if (!pScrPriv) { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nCrtcs = 0; - rep.nOutputs = 0; - rep.nModes = 0; - rep.nbytesNames = 0; + rep = (xRRGetScreenResourcesReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .timestamp = currentTime.milliseconds, + .configTimestamp = currentTime.milliseconds, + .nCrtcs = 0, + .nOutputs = 0, + .nModes = 0, + .nbytesNames = 0 + }; extra = NULL; extraLen = 0; } @@ -511,15 +514,18 @@ rrGetScreenResources(ClientPtr client, Bool query) if (!modes) return BadAlloc; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.nCrtcs = pScrPriv->numCrtcs; - rep.nOutputs = pScrPriv->numOutputs; - rep.nModes = num_modes; - rep.nbytesNames = 0; + rep = (xRRGetScreenResourcesReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .timestamp = pScrPriv->lastSetTime.milliseconds, + .configTimestamp = pScrPriv->lastConfigTime.milliseconds, + .nCrtcs = pScrPriv->numCrtcs, + .nOutputs = pScrPriv->numOutputs, + .nModes = num_modes, + .nbytesNames = 0 + }; + for (i = 0; i < num_modes; i++) rep.nbytesNames += modes[i]->mode.nameLength; @@ -744,7 +750,6 @@ ProcRRGetScreenInfo(ClientPtr client) pScreen = pWin->drawable.pScreen; pScrPriv = rrGetScrPriv(pScreen); - rep.pad = 0; if (pScrPriv) if (!RRGetInfo(pScreen, TRUE)) @@ -753,18 +758,20 @@ ProcRRGetScreenInfo(ClientPtr client) output = RRFirstOutput(pScreen); if (!pScrPriv || !output) { - rep.type = X_Reply; - rep.setOfRotations = RR_Rotate_0; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = pWin->drawable.pScreen->root->drawable.id; - rep.timestamp = currentTime.milliseconds; - rep.configTimestamp = currentTime.milliseconds; - rep.nSizes = 0; - rep.sizeID = 0; - rep.rotation = RR_Rotate_0; - rep.rate = 0; - rep.nrateEnts = 0; + rep = (xRRGetScreenInfoReply) { + .type = X_Reply, + .setOfRotations = RR_Rotate_0, + .sequenceNumber = client->sequence, + .length = 0, + .root = pWin->drawable.pScreen->root->drawable.id, + .timestamp = currentTime.milliseconds, + .configTimestamp = currentTime.milliseconds, + .nSizes = 0, + .sizeID = 0, + .rotation = RR_Rotate_0, + .rate = 0, + .nrateEnts = 0 + }; extra = 0; extraLen = 0; } @@ -781,18 +788,20 @@ ProcRRGetScreenInfo(ClientPtr client) if (!pData) return BadAlloc; - rep.type = X_Reply; - rep.setOfRotations = output->crtc->rotations; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.root = pWin->drawable.pScreen->root->drawable.id; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.rotation = output->crtc->rotation; - rep.nSizes = pData->nsize; - rep.nrateEnts = pData->nrefresh + pData->nsize; - rep.sizeID = pData->size; - rep.rate = pData->refresh; + rep = (xRRGetScreenInfoReply) { + .type = X_Reply, + .setOfRotations = output->crtc->rotations, + .sequenceNumber = client->sequence, + .length = 0, + .root = pWin->drawable.pScreen->root->drawable.id, + .timestamp = pScrPriv->lastSetTime.milliseconds, + .configTimestamp = pScrPriv->lastConfigTime.milliseconds, + .rotation = output->crtc->rotation, + .nSizes = pData->nsize, + .nrateEnts = pData->nrefresh + pData->nsize, + .sizeID = pData->size, + .rate = pData->refresh + }; extraLen = rep.nSizes * sizeof(xScreenSizes); if (has_rate) @@ -1078,14 +1087,17 @@ ProcRRSetScreenConfig(ClientPtr client) free(pData); - rep.type = X_Reply; - rep.status = status; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; - rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.root = pDraw->pScreen->root->drawable.id; + rep = (xRRSetScreenConfigReply) { + .type = X_Reply, + .status = status, + .sequenceNumber = client->sequence, + .length = 0, + + .newTimestamp = pScrPriv->lastSetTime.milliseconds, + .newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds, + .root = pDraw->pScreen->root->drawable.id, + /* .subpixelOrder = ?? */ + }; if (client->swapped) { swaps(&rep.sequenceNumber); diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c index da3942f6a..87d6a73e8 100644 --- a/randr/rrxinerama.c +++ b/randr/rrxinerama.c @@ -89,14 +89,15 @@ static int SProcRRXineramaDispatch(ClientPtr client); int ProcRRXineramaQueryVersion(ClientPtr client) { - xPanoramiXQueryVersionReply rep; + xPanoramiXQueryVersionReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION, + .minorVersion = SERVER_RRXINERAMA_MINOR_VERSION + }; REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION; - rep.minorVersion = SERVER_RRXINERAMA_MINOR_VERSION; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -130,11 +131,13 @@ ProcRRXineramaGetState(ClientPtr client) active = TRUE; } - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.state = active; - rep.window = stuff->window; + rep = (xPanoramiXGetStateReply) { + .type = X_Reply, + .state = active, + .sequenceNumber = client->sequence, + .length = 0, + .window = stuff->window + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -184,11 +187,13 @@ ProcRRXineramaGetScreenCount(ClientPtr client) if (rc != Success) return rc; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.ScreenCount = RRXineramaScreenCount(pWin->drawable.pScreen); - rep.window = stuff->window; + rep = (xPanoramiXGetScreenCountReply) { + .type = X_Reply, + .ScreenCount = RRXineramaScreenCount(pWin->drawable.pScreen), + .sequenceNumber = client->sequence, + .length = 0, + .window = stuff->window + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -215,13 +220,15 @@ ProcRRXineramaGetScreenSize(ClientPtr client) pScreen = pWin->drawable.pScreen; pRoot = pScreen->root; - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.width = pRoot->drawable.width; - rep.height = pRoot->drawable.height; - rep.window = stuff->window; - rep.screen = stuff->screen; + rep = (xPanoramiXGetScreenSizeReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .width = pRoot->drawable.width, + .height = pRoot->drawable.height, + .window = stuff->window, + .screen = stuff->screen + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -241,11 +248,12 @@ ProcRRXineramaIsActive(ClientPtr client) REQUEST_SIZE_MATCH(xXineramaIsActiveReq); - memset(&rep, 0, sizeof(xXineramaIsActiveReply)); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.state = RRXineramaScreenActive(screenInfo.screens[RR_XINERAMA_SCREEN]); + rep = (xXineramaIsActiveReply) { + .type = X_Reply, + .length = 0, + .sequenceNumber = client->sequence, + .state = RRXineramaScreenActive(screenInfo.screens[RR_XINERAMA_SCREEN]) + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -308,10 +316,12 @@ ProcRRXineramaQueryScreens(ClientPtr client) n = RRXineramaScreenCount(pScreen); } - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.number = n; - rep.length = bytes_to_int32(n * sz_XineramaScreenInfo); + rep = (xXineramaQueryScreensReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(n * sz_XineramaScreenInfo), + .number = n + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); |