[PATCH v2 19/29] Use C99 designated initializers in randr Replies
Alan Coopersmith
alan.coopersmith at oracle.com
Wed Jul 4 15:37:33 PDT 2012
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
randr/rrcrtc.c | 69 +++++++++++++++++------------
randr/rrdispatch.c | 9 ++--
randr/rrmode.c | 13 +++---
randr/rroutput.c | 42 +++++++++---------
randr/rrproperty.c | 32 +++++++++-----
randr/rrscreen.c | 124 ++++++++++++++++++++++++++++------------------------
randr/rrxinerama.c | 74 +++++++++++++++++--------------
7 files changed, 204 insertions(+), 159 deletions(-)
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 3b9f2dd..aa9b44f 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -729,11 +729,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))
@@ -990,11 +992,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);
@@ -1030,12 +1034,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)) {
@@ -1129,11 +1134,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);
@@ -1158,10 +1165,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);
@@ -1195,10 +1204,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 d4b9feb..fc9bcf3 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 7e17d7d..56e5977 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 3662a5a..0932508 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 b0a1cf9..7ce085c 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 47147d6..da6a207 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))
@@ -315,22 +317,23 @@ rrGetScreenResources(ClientPtr client, Bool query)
pScreen = pWin->drawable.pScreen;
pScrPriv = rrGetScrPriv(pScreen);
- rep.pad = 0;
if (query && pScrPriv)
if (!RRGetInfo(pScreen, query))
return BadAlloc;
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;
}
@@ -342,15 +345,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;
@@ -575,7 +581,6 @@ ProcRRGetScreenInfo(ClientPtr client)
pScreen = pWin->drawable.pScreen;
pScrPriv = rrGetScrPriv(pScreen);
- rep.pad = 0;
if (pScrPriv)
if (!RRGetInfo(pScreen, TRUE))
@@ -584,18 +589,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;
}
@@ -612,18 +619,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)
@@ -909,14 +918,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 da3942f..87d6a73 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);
--
1.7.9.2
More information about the xorg-devel
mailing list