randr: use struct initializer for reply structs

Improve readability, move the declarations to where they're needed first
and get rid of extra individual assignments. In some cases this should also
allow the compiler to produce a bit more efficient code.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-29 15:47:10 +02:00 committed by Marge Bot
parent 6d2c42d0c8
commit 7eff742ef2
12 changed files with 88 additions and 197 deletions

View File

@ -1022,18 +1022,16 @@ static void
RRModeGetScanoutSize(RRModePtr mode, PictTransformPtr transform, RRModeGetScanoutSize(RRModePtr mode, PictTransformPtr transform,
int *width, int *height) int *width, int *height)
{ {
BoxRec box;
if (mode == NULL) { if (mode == NULL) {
*width = 0; *width = 0;
*height = 0; *height = 0;
return; return;
} }
box.x1 = 0; BoxRec box = {
box.y1 = 0; .x2 = mode->mode.width,
box.x2 = mode->mode.width; .y2 = mode->mode.height,
box.y2 = mode->mode.height; };
pixman_transform_bounds(transform, &box); pixman_transform_bounds(transform, &box);
*width = box.x2 - box.x1; *width = box.x2 - box.x1;
@ -1147,10 +1145,9 @@ int
ProcRRGetCrtcInfo(ClientPtr client) ProcRRGetCrtcInfo(ClientPtr client)
{ {
REQUEST(xRRGetCrtcInfoReq); REQUEST(xRRGetCrtcInfoReq);
xRRGetCrtcInfoReply rep;
RRCrtcPtr crtc; RRCrtcPtr crtc;
CARD8 *extra = NULL; CARD8 *extra = NULL;
unsigned long extraLen; unsigned long extraLen = 0;
ScreenPtr pScreen; ScreenPtr pScreen;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
RRModePtr mode; RRModePtr mode;
@ -1174,22 +1171,17 @@ ProcRRGetCrtcInfo(ClientPtr client)
mode = crtc->mode; mode = crtc->mode;
rep = (xRRGetCrtcInfoReply) { xRRGetCrtcInfoReply rep = {
.type = X_Reply, .type = X_Reply,
.status = RRSetConfigSuccess, .status = RRSetConfigSuccess,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0, .timestamp = pScrPriv->lastSetTime.milliseconds,
.timestamp = pScrPriv->lastSetTime.milliseconds .rotation = crtc->rotation,
.rotations = crtc->rotations,
}; };
if (leased) { if (leased) {
rep.x = rep.y = rep.width = rep.height = 0;
rep.mode = 0;
rep.rotation = RR_Rotate_0; rep.rotation = RR_Rotate_0;
rep.rotations = RR_Rotate_0; rep.rotations = RR_Rotate_0;
rep.nOutput = 0;
rep.nPossibleOutput = 0;
rep.length = 0;
extraLen = 0;
} else { } else {
if (pScrPriv->rrGetPanning && if (pScrPriv->rrGetPanning &&
pScrPriv->rrGetPanning(pScreen, crtc, &panned_area, NULL, NULL) && pScrPriv->rrGetPanning(pScreen, crtc, &panned_area, NULL, NULL) &&
@ -1208,23 +1200,18 @@ ProcRRGetCrtcInfo(ClientPtr client)
rep.height = height; rep.height = height;
} }
rep.mode = mode ? mode->mode.id : 0; rep.mode = mode ? mode->mode.id : 0;
rep.rotation = crtc->rotation;
rep.rotations = crtc->rotations;
rep.nOutput = crtc->numOutputs; rep.nOutput = crtc->numOutputs;
k = 0;
for (i = 0; i < pScrPriv->numOutputs; i++) { for (i = 0; i < pScrPriv->numOutputs; i++) {
if (!RROutputIsLeased(pScrPriv->outputs[i])) { if (!RROutputIsLeased(pScrPriv->outputs[i])) {
for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++) for (j = 0; j < pScrPriv->outputs[i]->numCrtcs; j++)
if (pScrPriv->outputs[i]->crtcs[j] == crtc) if (pScrPriv->outputs[i]->crtcs[j] == crtc)
k++; rep.nPossibleOutput++;
} }
} }
rep.nPossibleOutput = k; extraLen = (rep.nOutput + rep.nPossibleOutput) * sizeof(CARD32);
rep.length = bytes_to_int32(extraLen);
rep.length = rep.nOutput + rep.nPossibleOutput;
extraLen = rep.length << 2;
if (extraLen) { if (extraLen) {
extra = malloc(extraLen); extra = malloc(extraLen);
if (!extra) if (!extra)
@ -1283,7 +1270,6 @@ int
ProcRRSetCrtcConfig(ClientPtr client) ProcRRSetCrtcConfig(ClientPtr client)
{ {
REQUEST(xRRSetCrtcConfigReq); REQUEST(xRRSetCrtcConfigReq);
xRRSetCrtcConfigReply rep;
ScreenPtr pScreen; ScreenPtr pScreen;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
RRCrtcPtr crtc; RRCrtcPtr crtc;
@ -1475,11 +1461,10 @@ ProcRRSetCrtcConfig(ClientPtr client)
sendReply: sendReply:
free(outputs); free(outputs);
rep = (xRRSetCrtcConfigReply) { xRRSetCrtcConfigReply rep = {
.type = X_Reply, .type = X_Reply,
.status = status, .status = status,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.newTimestamp = pScrPriv->lastSetTime.milliseconds .newTimestamp = pScrPriv->lastSetTime.milliseconds
}; };
@ -1497,7 +1482,6 @@ int
ProcRRGetPanning(ClientPtr client) ProcRRGetPanning(ClientPtr client)
{ {
REQUEST(xRRGetPanningReq); REQUEST(xRRGetPanningReq);
xRRGetPanningReply rep;
RRCrtcPtr crtc; RRCrtcPtr crtc;
ScreenPtr pScreen; ScreenPtr pScreen;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
@ -1517,7 +1501,7 @@ ProcRRGetPanning(ClientPtr client)
if (!pScrPriv) if (!pScrPriv)
return RRErrorBase + BadRRCrtc; return RRErrorBase + BadRRCrtc;
rep = (xRRGetPanningReply) { xRRGetPanningReply rep = {
.type = X_Reply, .type = X_Reply,
.status = RRSetConfigSuccess, .status = RRSetConfigSuccess,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
@ -1641,7 +1625,6 @@ int
ProcRRGetCrtcGammaSize(ClientPtr client) ProcRRGetCrtcGammaSize(ClientPtr client)
{ {
REQUEST(xRRGetCrtcGammaSizeReq); REQUEST(xRRGetCrtcGammaSizeReq);
xRRGetCrtcGammaSizeReply reply;
RRCrtcPtr crtc; RRCrtcPtr crtc;
REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq); REQUEST_SIZE_MATCH(xRRGetCrtcGammaSizeReq);
@ -1651,10 +1634,9 @@ ProcRRGetCrtcGammaSize(ClientPtr client)
if (!RRCrtcGammaGet(crtc)) if (!RRCrtcGammaGet(crtc))
return RRErrorBase + BadRRCrtc; return RRErrorBase + BadRRCrtc;
reply = (xRRGetCrtcGammaSizeReply) { xRRGetCrtcGammaSizeReply reply = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.size = crtc->gammaSize .size = crtc->gammaSize
}; };
if (client->swapped) { if (client->swapped) {
@ -1670,7 +1652,6 @@ int
ProcRRGetCrtcGamma(ClientPtr client) ProcRRGetCrtcGamma(ClientPtr client)
{ {
REQUEST(xRRGetCrtcGammaReq); REQUEST(xRRGetCrtcGammaReq);
xRRGetCrtcGammaReply reply;
RRCrtcPtr crtc; RRCrtcPtr crtc;
unsigned long len; unsigned long len;
char *extra = NULL; char *extra = NULL;
@ -1690,7 +1671,7 @@ ProcRRGetCrtcGamma(ClientPtr client)
return BadAlloc; return BadAlloc;
} }
reply = (xRRGetCrtcGammaReply) { xRRGetCrtcGammaReply reply = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(len), .length = bytes_to_int32(len),

View File

@ -42,7 +42,6 @@ ProcRRQueryVersion(ClientPtr client)
xRRQueryVersionReply rep = { xRRQueryVersionReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0
}; };
REQUEST(xRRQueryVersionReq); REQUEST(xRRQueryVersionReq);
rrClientPriv(client); rrClientPriv(client);

View File

@ -250,19 +250,18 @@ RRRegisterSize(ScreenPtr pScreen,
{ {
rrScrPriv(pScreen); rrScrPriv(pScreen);
int i; int i;
RRScreenSize tmp;
RRScreenSizePtr pNew; RRScreenSizePtr pNew;
if (!pScrPriv) if (!pScrPriv)
return 0; return 0;
tmp.id = 0; RRScreenSize tmp = {
tmp.width = width; .width = width,
tmp.height = height; .height = height,
tmp.mmWidth = mmWidth; .mmWidth = mmWidth,
tmp.mmHeight = mmHeight; .mmHeight = mmHeight,
tmp.pRates = 0; };
tmp.nRates = 0;
for (i = 0; i < pScrPriv->nSizes; i++) for (i = 0; i < pScrPriv->nSizes; i++)
if (RRScreenSizeMatches(&tmp, &pScrPriv->pSizes[i])) if (RRScreenSizeMatches(&tmp, &pScrPriv->pSizes[i]))
return &pScrPriv->pSizes[i]; return &pScrPriv->pSizes[i];

View File

@ -213,7 +213,6 @@ int
ProcRRCreateLease(ClientPtr client) ProcRRCreateLease(ClientPtr client)
{ {
REQUEST(xRRCreateLeaseReq); REQUEST(xRRCreateLeaseReq);
xRRCreateLeaseReply rep;
WindowPtr window; WindowPtr window;
ScreenPtr screen; ScreenPtr screen;
rrScrPrivPtr scr_priv; rrScrPrivPtr scr_priv;
@ -334,11 +333,10 @@ leaseReturned:
RRLeaseChangeState(lease, RRLeaseCreating, RRLeaseRunning); RRLeaseChangeState(lease, RRLeaseCreating, RRLeaseRunning);
rep = (xRRCreateLeaseReply) { xRRCreateLeaseReply rep = {
.type = X_Reply, .type = X_Reply,
.nfd = 1, .nfd = 1,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
}; };
if (client->swapped) { if (client->swapped) {

View File

@ -286,7 +286,6 @@ int
ProcRRCreateMode(ClientPtr client) ProcRRCreateMode(ClientPtr client)
{ {
REQUEST(xRRCreateModeReq); REQUEST(xRRCreateModeReq);
xRRCreateModeReply rep;
WindowPtr pWin; WindowPtr pWin;
ScreenPtr pScreen; ScreenPtr pScreen;
xRRModeInfo *modeInfo; xRRModeInfo *modeInfo;
@ -314,12 +313,12 @@ ProcRRCreateMode(ClientPtr client)
if (!mode) if (!mode)
return error; return error;
rep = (xRRCreateModeReply) { xRRCreateModeReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.mode = mode->mode.id .mode = mode->mode.id
}; };
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);
swapl(&rep.length); swapl(&rep.length);

View File

@ -581,11 +581,6 @@ int
ProcRRGetMonitors(ClientPtr client) ProcRRGetMonitors(ClientPtr client)
{ {
REQUEST(xRRGetMonitorsReq); REQUEST(xRRGetMonitorsReq);
xRRGetMonitorsReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
};
WindowPtr window; WindowPtr window;
ScreenPtr screen; ScreenPtr screen;
int r; int r;
@ -604,17 +599,19 @@ ProcRRGetMonitors(ClientPtr client)
if (!RRMonitorMakeList(screen, get_active, &monitors, &nmonitors)) if (!RRMonitorMakeList(screen, get_active, &monitors, &nmonitors))
return BadAlloc; return BadAlloc;
rep.timestamp = RRMonitorTimestamp(screen);
noutputs = 0; noutputs = 0;
for (m = 0; m < nmonitors; m++) { for (m = 0; m < nmonitors; m++) {
rep.length += SIZEOF(xRRMonitorInfo) >> 2;
rep.length += monitors[m].numOutputs;
noutputs += monitors[m].numOutputs; noutputs += monitors[m].numOutputs;
} }
rep.nmonitors = nmonitors; xRRGetMonitorsReply rep = {
rep.noutputs = noutputs; .type = X_Reply,
.sequenceNumber = client->sequence,
.timestamp = RRMonitorTimestamp(screen),
.length = noutputs + nmonitors * bytes_to_int32(sizeof(xRRMonitorInfo)),
.nmonitors = nmonitors,
.noutputs = noutputs,
};
if (client->swapped) { if (client->swapped) {
swaps(&rep.sequenceNumber); swaps(&rep.sequenceNumber);

View File

@ -481,15 +481,8 @@ ProcRRGetOutputInfo(ClientPtr client)
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(OutputInfoExtra), .length = bytes_to_int32(OutputInfoExtra),
.timestamp = pScrPriv->lastSetTime.milliseconds, .timestamp = pScrPriv->lastSetTime.milliseconds,
.crtc = None,
.mmWidth = 0,
.mmHeight = 0,
.connection = RR_Disconnected, .connection = RR_Disconnected,
.subpixelOrder = SubPixelUnknown, .subpixelOrder = SubPixelUnknown,
.nCrtcs = 0,
.nModes = 0,
.nPreferred = 0,
.nClones = 0,
.nameLength = output->nameLength .nameLength = output->nameLength
}; };
extraLen = bytes_to_int32(rep.nameLength) << 2; extraLen = bytes_to_int32(rep.nameLength) << 2;
@ -658,7 +651,6 @@ ProcRRGetOutputPrimary(ClientPtr client)
REQUEST(xRRGetOutputPrimaryReq); REQUEST(xRRGetOutputPrimaryReq);
WindowPtr pWin; WindowPtr pWin;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
xRRGetOutputPrimaryReply rep;
RROutputPtr primary = NULL; RROutputPtr primary = NULL;
int rc; int rc;
@ -672,7 +664,7 @@ ProcRRGetOutputPrimary(ClientPtr client)
if (pScrPriv) if (pScrPriv)
primary = pScrPriv->primaryOutput; primary = pScrPriv->primaryOutput;
rep = (xRRGetOutputPrimaryReply) { xRRGetOutputPrimaryReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.output = primary ? primary->id : None .output = primary ? primary->id : None

View File

@ -417,7 +417,6 @@ ProcRRListOutputProperties(ClientPtr client)
{ {
REQUEST(xRRListOutputPropertiesReq); REQUEST(xRRListOutputPropertiesReq);
Atom *pAtoms = NULL; Atom *pAtoms = NULL;
xRRListOutputPropertiesReply rep;
int numProps = 0; int numProps = 0;
RROutputPtr output; RROutputPtr output;
RRPropertyPtr prop; RRPropertyPtr prop;
@ -432,7 +431,7 @@ ProcRRListOutputProperties(ClientPtr client)
if (!(pAtoms = xallocarray(numProps, sizeof(Atom)))) if (!(pAtoms = xallocarray(numProps, sizeof(Atom))))
return BadAlloc; return BadAlloc;
rep = (xRRListOutputPropertiesReply) { xRRListOutputPropertiesReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(numProps * sizeof(Atom)), .length = bytes_to_int32(numProps * sizeof(Atom)),
@ -462,7 +461,6 @@ int
ProcRRQueryOutputProperty(ClientPtr client) ProcRRQueryOutputProperty(ClientPtr client)
{ {
REQUEST(xRRQueryOutputPropertyReq); REQUEST(xRRQueryOutputPropertyReq);
xRRQueryOutputPropertyReply rep;
RROutputPtr output; RROutputPtr output;
RRPropertyPtr prop; RRPropertyPtr prop;
char *extra = NULL; char *extra = NULL;
@ -481,7 +479,7 @@ ProcRRQueryOutputProperty(ClientPtr client)
return BadAlloc; return BadAlloc;
} }
rep = (xRRQueryOutputPropertyReply) { xRRQueryOutputPropertyReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = prop->num_valid, .length = prop->num_valid,
@ -620,7 +618,6 @@ ProcRRGetOutputProperty(ClientPtr client)
RRPropertyValuePtr prop_value; RRPropertyValuePtr prop_value;
unsigned long n, len, ind; unsigned long n, len, ind;
RROutputPtr output; RROutputPtr output;
xRRGetOutputPropertyReply reply;
char *extra = NULL; char *extra = NULL;
REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq); REQUEST_SIZE_MATCH(xRRGetOutputPropertyReq);
@ -646,22 +643,14 @@ ProcRRGetOutputProperty(ClientPtr client)
if (prop->propertyName == stuff->property) if (prop->propertyName == stuff->property)
break; break;
reply = (xRRGetOutputPropertyReply) { xRRGetOutputPropertyReply reply = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence .sequenceNumber = client->sequence
}; };
if (!prop) { if (!prop) {
reply.nItems = 0;
reply.length = 0;
reply.bytesAfter = 0;
reply.propertyType = None;
reply.format = 0;
if (client->swapped) { if (client->swapped) {
swaps(&reply.sequenceNumber); swaps(&reply.sequenceNumber);
swapl(&reply.length);
swapl(&reply.propertyType);
swapl(&reply.bytesAfter);
swapl(&reply.nItems);
} }
WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
return Success; return Success;
@ -681,15 +670,11 @@ ProcRRGetOutputProperty(ClientPtr client)
) { ) {
reply.bytesAfter = prop_value->size; reply.bytesAfter = prop_value->size;
reply.format = prop_value->format; reply.format = prop_value->format;
reply.length = 0;
reply.nItems = 0;
reply.propertyType = prop_value->type; reply.propertyType = prop_value->type;
if (client->swapped) { if (client->swapped) {
swaps(&reply.sequenceNumber); swaps(&reply.sequenceNumber);
swapl(&reply.length);
swapl(&reply.propertyType); swapl(&reply.propertyType);
swapl(&reply.bytesAfter); swapl(&reply.bytesAfter);
swapl(&reply.nItems);
} }
WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply); WriteToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
return Success; return Success;
@ -721,8 +706,6 @@ ProcRRGetOutputProperty(ClientPtr client)
reply.length = bytes_to_int32(len); reply.length = bytes_to_int32(len);
if (prop_value->format) if (prop_value->format)
reply.nItems = len / (prop_value->format / 8); reply.nItems = len / (prop_value->format / 8);
else
reply.nItems = 0;
reply.propertyType = prop_value->type; reply.propertyType = prop_value->type;
if (stuff->delete && (reply.bytesAfter == 0)) { if (stuff->delete && (reply.bytesAfter == 0)) {

View File

@ -56,7 +56,6 @@ int
ProcRRGetProviders (ClientPtr client) ProcRRGetProviders (ClientPtr client)
{ {
REQUEST(xRRGetProvidersReq); REQUEST(xRRGetProvidersReq);
xRRGetProvidersReply rep;
WindowPtr pWin; WindowPtr pWin;
ScreenPtr pScreen; ScreenPtr pScreen;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
@ -87,36 +86,36 @@ ProcRRGetProviders (ClientPtr client)
if (!pScrPriv) if (!pScrPriv)
{ {
rep = (xRRGetProvidersReply) { xRRGetProvidersReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.timestamp = currentTime.milliseconds, .timestamp = currentTime.milliseconds,
.nProviders = 0
}; };
extra = NULL; WriteToClient(client, sizeof(rep), &rep);
extraLen = 0; return Success;
} else { }
rep = (xRRGetProvidersReply) {
.type = X_Reply,
.sequenceNumber = client->sequence,
.timestamp = pScrPriv->lastSetTime.milliseconds,
.nProviders = total_providers,
.length = total_providers
};
extraLen = rep.length << 2;
if (extraLen) {
extra = malloc(extraLen);
if (!extra)
return BadAlloc;
} else
extra = NULL;
providers = (RRProvider *)extra; extraLen = total_providers * sizeof(CARD32);
ADD_PROVIDER(pScreen);
xorg_list_for_each_entry(iter, &pScreen->secondary_list, secondary_head) { xRRGetProvidersReply rep = {
ADD_PROVIDER(iter); .type = X_Reply,
} .sequenceNumber = client->sequence,
.timestamp = pScrPriv->lastSetTime.milliseconds,
.nProviders = total_providers,
.length = bytes_to_int32(extraLen),
};
if (extraLen) {
extra = malloc(extraLen);
if (!extra)
return BadAlloc;
} else
extra = NULL;
providers = (RRProvider *)extra;
ADD_PROVIDER(pScreen);
xorg_list_for_each_entry(iter, &pScreen->secondary_list, secondary_head) {
ADD_PROVIDER(iter);
} }
if (client->swapped) { if (client->swapped) {
@ -138,7 +137,6 @@ int
ProcRRGetProviderInfo (ClientPtr client) ProcRRGetProviderInfo (ClientPtr client)
{ {
REQUEST(xRRGetProviderInfoReq); REQUEST(xRRGetProviderInfoReq);
xRRGetProviderInfoReply rep;
rrScrPrivPtr pScrPriv, pScrProvPriv; rrScrPrivPtr pScrPriv, pScrProvPriv;
RRProviderPtr provider; RRProviderPtr provider;
ScreenPtr pScreen; ScreenPtr pScreen;
@ -158,17 +156,15 @@ ProcRRGetProviderInfo (ClientPtr client)
pScreen = provider->pScreen; pScreen = provider->pScreen;
pScrPriv = rrGetScrPriv(pScreen); pScrPriv = rrGetScrPriv(pScreen);
rep = (xRRGetProviderInfoReply) { xRRGetProviderInfoReply rep = {
.type = X_Reply, .type = X_Reply,
.status = RRSetConfigSuccess, .status = RRSetConfigSuccess,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.capabilities = provider->capabilities, .capabilities = provider->capabilities,
.nameLength = provider->nameLength, .nameLength = provider->nameLength,
.timestamp = pScrPriv->lastSetTime.milliseconds, .timestamp = pScrPriv->lastSetTime.milliseconds,
.nCrtcs = pScrPriv->numCrtcs, .nCrtcs = pScrPriv->numCrtcs,
.nOutputs = pScrPriv->numOutputs, .nOutputs = pScrPriv->numOutputs,
.nAssociatedProviders = 0
}; };
/* count associated providers */ /* count associated providers */

View File

@ -391,7 +391,6 @@ ProcRRListProviderProperties(ClientPtr client)
{ {
REQUEST(xRRListProviderPropertiesReq); REQUEST(xRRListProviderPropertiesReq);
Atom *pAtoms = NULL, *temppAtoms; Atom *pAtoms = NULL, *temppAtoms;
xRRListProviderPropertiesReply rep;
int numProps = 0; int numProps = 0;
RRProviderPtr provider; RRProviderPtr provider;
RRPropertyPtr prop; RRPropertyPtr prop;
@ -406,7 +405,7 @@ ProcRRListProviderProperties(ClientPtr client)
if (!(pAtoms = xallocarray(numProps, sizeof(Atom)))) if (!(pAtoms = xallocarray(numProps, sizeof(Atom))))
return BadAlloc; return BadAlloc;
rep = (xRRListProviderPropertiesReply) { xRRListProviderPropertiesReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(numProps * sizeof(Atom)), .length = bytes_to_int32(numProps * sizeof(Atom)),
@ -434,7 +433,6 @@ int
ProcRRQueryProviderProperty(ClientPtr client) ProcRRQueryProviderProperty(ClientPtr client)
{ {
REQUEST(xRRQueryProviderPropertyReq); REQUEST(xRRQueryProviderPropertyReq);
xRRQueryProviderPropertyReply rep;
RRProviderPtr provider; RRProviderPtr provider;
RRPropertyPtr prop; RRPropertyPtr prop;
char *extra = NULL; char *extra = NULL;
@ -452,7 +450,8 @@ ProcRRQueryProviderProperty(ClientPtr client)
if (!extra) if (!extra)
return BadAlloc; return BadAlloc;
} }
rep = (xRRQueryProviderPropertyReply) {
xRRQueryProviderPropertyReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = prop->num_valid, .length = prop->num_valid,
@ -614,17 +613,8 @@ ProcRRGetProviderProperty(ClientPtr client)
break; break;
if (!prop) { if (!prop) {
reply.nItems = 0;
reply.length = 0;
reply.bytesAfter = 0;
reply.propertyType = None;
reply.format = 0;
if (client->swapped) { if (client->swapped) {
swaps(&reply.sequenceNumber); swaps(&reply.sequenceNumber);
swapl(&reply.length);
swapl(&reply.propertyType);
swapl(&reply.bytesAfter);
swapl(&reply.nItems);
} }
WriteToClient(client, sizeof(xRRGetProviderPropertyReply), &reply); WriteToClient(client, sizeof(xRRGetProviderPropertyReply), &reply);
return Success; return Success;
@ -644,15 +634,11 @@ ProcRRGetProviderProperty(ClientPtr client)
) { ) {
reply.bytesAfter = prop_value->size; reply.bytesAfter = prop_value->size;
reply.format = prop_value->format; reply.format = prop_value->format;
reply.length = 0;
reply.nItems = 0;
reply.propertyType = prop_value->type; reply.propertyType = prop_value->type;
if (client->swapped) { if (client->swapped) {
swaps(&reply.sequenceNumber); swaps(&reply.sequenceNumber);
swapl(&reply.length);
swapl(&reply.propertyType); swapl(&reply.propertyType);
swapl(&reply.bytesAfter); swapl(&reply.bytesAfter);
swapl(&reply.nItems);
} }
WriteToClient(client, sizeof(xRRGetProviderPropertyReply), &reply); WriteToClient(client, sizeof(xRRGetProviderPropertyReply), &reply);
return Success; return Success;
@ -684,8 +670,6 @@ ProcRRGetProviderProperty(ClientPtr client)
reply.length = bytes_to_int32(len); reply.length = bytes_to_int32(len);
if (prop_value->format) if (prop_value->format)
reply.nItems = len / (prop_value->format / 8); reply.nItems = len / (prop_value->format / 8);
else
reply.nItems = 0;
reply.propertyType = prop_value->type; reply.propertyType = prop_value->type;
if (stuff->delete && (reply.bytesAfter == 0)) { if (stuff->delete && (reply.bytesAfter == 0)) {

View File

@ -76,8 +76,6 @@ RRSendConfigNotify(ScreenPtr pScreen)
xEvent event = { xEvent event = {
.u.configureNotify.window = pWin->drawable.id, .u.configureNotify.window = pWin->drawable.id,
.u.configureNotify.aboveSibling = None, .u.configureNotify.aboveSibling = None,
.u.configureNotify.x = 0,
.u.configureNotify.y = 0,
/* XXX xinerama stuff ? */ /* XXX xinerama stuff ? */
@ -192,7 +190,6 @@ int
ProcRRGetScreenSizeRange(ClientPtr client) ProcRRGetScreenSizeRange(ClientPtr client)
{ {
REQUEST(xRRGetScreenSizeRangeReq); REQUEST(xRRGetScreenSizeRangeReq);
xRRGetScreenSizeRangeReply rep;
WindowPtr pWin; WindowPtr pWin;
ScreenPtr pScreen; ScreenPtr pScreen;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
@ -206,11 +203,9 @@ ProcRRGetScreenSizeRange(ClientPtr client)
pScreen = pWin->drawable.pScreen; pScreen = pWin->drawable.pScreen;
pScrPriv = rrGetScrPriv(pScreen); pScrPriv = rrGetScrPriv(pScreen);
rep = (xRRGetScreenSizeRangeReply) { xRRGetScreenSizeRangeReply rep = {
.type = X_Reply, .type = X_Reply,
.pad = 0,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0
}; };
if (pScrPriv) { if (pScrPriv) {
@ -372,7 +367,6 @@ rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen)
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
int num_modes; int num_modes;
RRModePtr *modes; RRModePtr *modes;
xRRGetScreenResourcesReply rep;
unsigned long extraLen; unsigned long extraLen;
CARD8 *extra; CARD8 *extra;
RRCrtc *crtcs; RRCrtc *crtcs;
@ -409,10 +403,10 @@ rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen)
} }
pScrPriv = rrGetScrPriv(pScreen); pScrPriv = rrGetScrPriv(pScreen);
rep = (xRRGetScreenResourcesReply) {
xRRGetScreenResourcesReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.timestamp = pScrPriv->lastSetTime.milliseconds, .timestamp = pScrPriv->lastSetTime.milliseconds,
.configTimestamp = pScrPriv->lastConfigTime.milliseconds, .configTimestamp = pScrPriv->lastConfigTime.milliseconds,
.nCrtcs = total_crtcs, .nCrtcs = total_crtcs,
@ -491,8 +485,8 @@ rrGetScreenResources(ClientPtr client, Bool query)
WindowPtr pWin; WindowPtr pWin;
ScreenPtr pScreen; ScreenPtr pScreen;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
CARD8 *extra; CARD8 *extra = NULL;
unsigned long extraLen; unsigned long extraLen = 0;
int i, rc, has_primary = 0; int i, rc, has_primary = 0;
RRCrtc *crtcs; RRCrtc *crtcs;
RROutput *outputs; RROutput *outputs;
@ -518,16 +512,9 @@ rrGetScreenResources(ClientPtr client, Bool query)
rep = (xRRGetScreenResourcesReply) { rep = (xRRGetScreenResourcesReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.timestamp = currentTime.milliseconds, .timestamp = currentTime.milliseconds,
.configTimestamp = currentTime.milliseconds, .configTimestamp = currentTime.milliseconds,
.nCrtcs = 0,
.nOutputs = 0,
.nModes = 0,
.nbytesNames = 0
}; };
extra = NULL;
extraLen = 0;
} }
else { else {
RRModePtr *modes; RRModePtr *modes;
@ -540,16 +527,13 @@ rrGetScreenResources(ClientPtr client, Bool query)
rep = (xRRGetScreenResourcesReply) { rep = (xRRGetScreenResourcesReply) {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.timestamp = pScrPriv->lastSetTime.milliseconds, .timestamp = pScrPriv->lastSetTime.milliseconds,
.configTimestamp = pScrPriv->lastConfigTime.milliseconds, .configTimestamp = pScrPriv->lastConfigTime.milliseconds,
.nCrtcs = pScrPriv->numCrtcs, .nCrtcs = pScrPriv->numCrtcs,
.nOutputs = pScrPriv->numOutputs, .nOutputs = pScrPriv->numOutputs,
.nModes = num_modes, .nModes = num_modes,
.nbytesNames = 0
}; };
for (i = 0; i < num_modes; i++) for (i = 0; i < num_modes; i++)
rep.nbytesNames += modes[i]->mode.nameLength; rep.nbytesNames += modes[i]->mode.nameLength;
@ -762,8 +746,8 @@ ProcRRGetScreenInfo(ClientPtr client)
int rc; int rc;
ScreenPtr pScreen; ScreenPtr pScreen;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
CARD8 *extra; CARD8 *extra = NULL;
unsigned long extraLen; unsigned long extraLen = 0;
RROutputPtr output; RROutputPtr output;
REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
@ -785,18 +769,11 @@ ProcRRGetScreenInfo(ClientPtr client)
.type = X_Reply, .type = X_Reply,
.setOfRotations = RR_Rotate_0, .setOfRotations = RR_Rotate_0,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.root = pWin->drawable.pScreen->root->drawable.id, .root = pWin->drawable.pScreen->root->drawable.id,
.timestamp = currentTime.milliseconds, .timestamp = currentTime.milliseconds,
.configTimestamp = currentTime.milliseconds, .configTimestamp = currentTime.milliseconds,
.nSizes = 0,
.sizeID = 0,
.rotation = RR_Rotate_0, .rotation = RR_Rotate_0,
.rate = 0,
.nrateEnts = 0
}; };
extra = 0;
extraLen = 0;
} }
else { else {
int i, j; int i, j;
@ -815,7 +792,6 @@ ProcRRGetScreenInfo(ClientPtr client)
.type = X_Reply, .type = X_Reply,
.setOfRotations = output->crtc->rotations, .setOfRotations = output->crtc->rotations,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.root = pWin->drawable.pScreen->root->drawable.id, .root = pWin->drawable.pScreen->root->drawable.id,
.timestamp = pScrPriv->lastSetTime.milliseconds, .timestamp = pScrPriv->lastSetTime.milliseconds,
.configTimestamp = pScrPriv->lastConfigTime.milliseconds, .configTimestamp = pScrPriv->lastConfigTime.milliseconds,
@ -905,7 +881,6 @@ int
ProcRRSetScreenConfig(ClientPtr client) ProcRRSetScreenConfig(ClientPtr client)
{ {
REQUEST(xRRSetScreenConfigReq); REQUEST(xRRSetScreenConfigReq);
xRRSetScreenConfigReply rep;
DrawablePtr pDraw; DrawablePtr pDraw;
int rc; int rc;
ScreenPtr pScreen; ScreenPtr pScreen;
@ -1110,12 +1085,10 @@ ProcRRSetScreenConfig(ClientPtr client)
free(pData); free(pData);
rep = (xRRSetScreenConfigReply) { xRRSetScreenConfigReply rep = {
.type = X_Reply, .type = X_Reply,
.status = status, .status = status,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.newTimestamp = pScrPriv->lastSetTime.milliseconds, .newTimestamp = pScrPriv->lastSetTime.milliseconds,
.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds, .newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds,
.root = pDraw->pScreen->root->drawable.id, .root = pDraw->pScreen->root->drawable.id,

View File

@ -99,7 +99,6 @@ ProcRRXineramaQueryVersion(ClientPtr client)
xPanoramiXQueryVersionReply rep = { xPanoramiXQueryVersionReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION, .majorVersion = SERVER_RRXINERAMA_MAJOR_VERSION,
.minorVersion = SERVER_RRXINERAMA_MINOR_VERSION .minorVersion = SERVER_RRXINERAMA_MINOR_VERSION
}; };
@ -120,7 +119,6 @@ ProcRRXineramaGetState(ClientPtr client)
{ {
REQUEST(xPanoramiXGetStateReq); REQUEST(xPanoramiXGetStateReq);
WindowPtr pWin; WindowPtr pWin;
xPanoramiXGetStateReply rep;
register int rc; register int rc;
ScreenPtr pScreen; ScreenPtr pScreen;
rrScrPrivPtr pScrPriv; rrScrPrivPtr pScrPriv;
@ -138,11 +136,10 @@ ProcRRXineramaGetState(ClientPtr client)
active = TRUE; active = TRUE;
} }
rep = (xPanoramiXGetStateReply) { xPanoramiXGetStateReply rep = {
.type = X_Reply, .type = X_Reply,
.state = active, .state = active,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.window = stuff->window .window = stuff->window
}; };
if (client->swapped) { if (client->swapped) {
@ -171,7 +168,6 @@ ProcRRXineramaGetScreenCount(ClientPtr client)
{ {
REQUEST(xPanoramiXGetScreenCountReq); REQUEST(xPanoramiXGetScreenCountReq);
WindowPtr pWin; WindowPtr pWin;
xPanoramiXGetScreenCountReply rep;
register int rc; register int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq); REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
@ -179,11 +175,10 @@ ProcRRXineramaGetScreenCount(ClientPtr client)
if (rc != Success) if (rc != Success)
return rc; return rc;
rep = (xPanoramiXGetScreenCountReply) { xPanoramiXGetScreenCountReply rep = {
.type = X_Reply, .type = X_Reply,
.ScreenCount = RRXineramaScreenCount(pWin->drawable.pScreen), .ScreenCount = RRXineramaScreenCount(pWin->drawable.pScreen),
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.window = stuff->window .window = stuff->window
}; };
if (client->swapped) { if (client->swapped) {
@ -201,7 +196,6 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
REQUEST(xPanoramiXGetScreenSizeReq); REQUEST(xPanoramiXGetScreenSizeReq);
WindowPtr pWin, pRoot; WindowPtr pWin, pRoot;
ScreenPtr pScreen; ScreenPtr pScreen;
xPanoramiXGetScreenSizeReply rep;
register int rc; register int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq); REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
@ -212,10 +206,9 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
pScreen = pWin->drawable.pScreen; pScreen = pWin->drawable.pScreen;
pRoot = pScreen->root; pRoot = pScreen->root;
rep = (xPanoramiXGetScreenSizeReply) { xPanoramiXGetScreenSizeReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = 0,
.width = pRoot->drawable.width, .width = pRoot->drawable.width,
.height = pRoot->drawable.height, .height = pRoot->drawable.height,
.window = stuff->window, .window = stuff->window,
@ -236,13 +229,11 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
int int
ProcRRXineramaIsActive(ClientPtr client) ProcRRXineramaIsActive(ClientPtr client)
{ {
xXineramaIsActiveReply rep;
REQUEST_SIZE_MATCH(xXineramaIsActiveReq); REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
rep = (xXineramaIsActiveReply) { xXineramaIsActiveReply rep = {
.type = X_Reply, .type = X_Reply,
.length = 0,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.state = RRXineramaScreenActive(screenInfo.screens[RR_XINERAMA_SCREEN]) .state = RRXineramaScreenActive(screenInfo.screens[RR_XINERAMA_SCREEN])
}; };
@ -258,12 +249,12 @@ ProcRRXineramaIsActive(ClientPtr client)
static void static void
RRXineramaWriteMonitor(ClientPtr client, RRMonitorPtr monitor) RRXineramaWriteMonitor(ClientPtr client, RRMonitorPtr monitor)
{ {
xXineramaScreenInfo scratch; xXineramaScreenInfo scratch = {
.x_org = monitor->geometry.box.x1,
scratch.x_org = monitor->geometry.box.x1; .y_org = monitor->geometry.box.y1,
scratch.y_org = monitor->geometry.box.y1; .width = monitor->geometry.box.x2 - monitor->geometry.box.x1,
scratch.width = monitor->geometry.box.x2 - monitor->geometry.box.x1; .height = monitor->geometry.box.y2 - monitor->geometry.box.y1,
scratch.height = monitor->geometry.box.y2 - monitor->geometry.box.y1; };
if (client->swapped) { if (client->swapped) {
swaps(&scratch.x_org); swaps(&scratch.x_org);
@ -278,7 +269,6 @@ RRXineramaWriteMonitor(ClientPtr client, RRMonitorPtr monitor)
int int
ProcRRXineramaQueryScreens(ClientPtr client) ProcRRXineramaQueryScreens(ClientPtr client)
{ {
xXineramaQueryScreensReply rep;
ScreenPtr pScreen = screenInfo.screens[RR_XINERAMA_SCREEN]; ScreenPtr pScreen = screenInfo.screens[RR_XINERAMA_SCREEN];
int m; int m;
RRMonitorPtr monitors = NULL; RRMonitorPtr monitors = NULL;
@ -292,7 +282,7 @@ ProcRRXineramaQueryScreens(ClientPtr client)
return BadAlloc; return BadAlloc;
} }
rep = (xXineramaQueryScreensReply) { xXineramaQueryScreensReply rep = {
.type = X_Reply, .type = X_Reply,
.sequenceNumber = client->sequence, .sequenceNumber = client->sequence,
.length = bytes_to_int32(nmonitors * sz_XineramaScreenInfo), .length = bytes_to_int32(nmonitors * sz_XineramaScreenInfo),