From fb73f7f40fa46458990038332017d4496caa0691 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 14 Jul 2012 10:02:52 -0700 Subject: Fix two more C99 initialization mistakes using members of same struct Similar to 34cf559bcf99dad, use temporary variables instead of referencing members of the struct being initialized in the middle of the initialization. Signed-off-by: Alan Coopersmith Reviewed-by: Keith Packard --- Xext/panoramiX.c | 5 +++-- Xext/xvmc.c | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c index 5653c08e1..1c7197d5d 100644 --- a/Xext/panoramiX.c +++ b/Xext/panoramiX.c @@ -1056,11 +1056,12 @@ int ProcXineramaQueryScreens(ClientPtr client) { /* REQUEST(xXineramaQueryScreensReq); */ + CARD32 number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens; xXineramaQueryScreensReply rep = { .type = X_Reply, .sequenceNumber = client->sequence, - .length = bytes_to_int32(rep.number * sz_XineramaScreenInfo), - .number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens + .length = bytes_to_int32(number * sz_XineramaScreenInfo), + .number = number }; REQUEST_SIZE_MATCH(xXineramaQueryScreensReq); diff --git a/Xext/xvmc.c b/Xext/xvmc.c index 8d93cc3b0..5f0123b32 100644 --- a/Xext/xvmc.c +++ b/Xext/xvmc.c @@ -135,6 +135,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client) xvmcSurfaceInfo info; XvMCAdaptorPtr adaptor = NULL; XvMCSurfaceInfoPtr surface; + int num_surfaces; REQUEST(xvmcListSurfaceTypesReq); REQUEST_SIZE_MATCH(xvmcListSurfaceTypesReq); @@ -154,16 +155,17 @@ ProcXvMCListSurfaceTypes(ClientPtr client) } } + num_surfaces = (adaptor) ? adaptor->num_surfaces : 0; rep = (xvmcListSurfaceTypesReply) { .type = X_Reply, .sequenceNumber = client->sequence, - .num = (adaptor) ? adaptor->num_surfaces : 0, - .length = bytes_to_int32(rep.num * sizeof(xvmcSurfaceInfo)), + .num = num_surfaces, + .length = bytes_to_int32(num_surfaces * sizeof(xvmcSurfaceInfo)), }; WriteToClient(client, sizeof(xvmcListSurfaceTypesReply), &rep); - for (i = 0; i < rep.num; i++) { + for (i = 0; i < num_surfaces; i++) { surface = adaptor->surfaces[i]; info.surface_type_id = surface->surface_type_id; info.chroma_format = surface->chroma_format; -- cgit v1.2.3 From ada04ef0ca8a1213e865ba2c000ccd6ed6d0e371 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 14 Jul 2012 10:45:29 -0700 Subject: Use C99 designated initializers in RandR 1.4 extension Replies RandR 1.4 was going through review in parallel with main batch of C99 initialization changes - sync up now that both have landed. Signed-off-by: Alan Coopersmith Reviewed-by: Keith Packard --- randr/rrprovider.c | 47 +++++++++++++++++++++++++--------------------- randr/rrproviderproperty.c | 31 +++++++++++++++++------------- randr/rrscreen.c | 21 +++++++++++---------- 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/randr/rrprovider.c b/randr/rrprovider.c index c4fe36980..c4ed515d6 100644 --- a/randr/rrprovider.c +++ b/randr/rrprovider.c @@ -86,23 +86,26 @@ ProcRRGetProviders (ClientPtr client) } pScrPriv = rrGetScrPriv(pScreen); - rep.pad = 0; if (!pScrPriv) { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = currentTime.milliseconds; - rep.nProviders = 0; + rep = (xRRGetProvidersReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .timestamp = currentTime.milliseconds, + .nProviders = 0 + }; extra = NULL; extraLen = 0; } else { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.nProviders = total_providers; - rep.length = total_providers; + 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); @@ -163,18 +166,20 @@ ProcRRGetProviderInfo (ClientPtr client) pScreen = provider->pScreen; pScrPriv = rrGetScrPriv(pScreen); - rep.type = X_Reply; - rep.status = RRSetConfigSuccess; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.capabilities = provider->capabilities; - rep.nameLength = provider->nameLength; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.nCrtcs = pScrPriv->numCrtcs; - rep.nOutputs = pScrPriv->numOutputs; + rep = (xRRGetProviderInfoReply) { + .type = X_Reply, + .status = RRSetConfigSuccess, + .sequenceNumber = client->sequence, + .length = 0, + .capabilities = provider->capabilities, + .nameLength = provider->nameLength, + .timestamp = pScrPriv->lastSetTime.milliseconds, + .nCrtcs = pScrPriv->numCrtcs, + .nOutputs = pScrPriv->numOutputs, + .nAssociatedProviders = 0 + }; /* count associated providers */ - rep.nAssociatedProviders = 0; if (provider->offload_sink) rep.nAssociatedProviders++; if (provider->output_source) diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c index 5e04fab8f..785f42c9a 100644 --- a/randr/rrproviderproperty.c +++ b/randr/rrproviderproperty.c @@ -394,10 +394,12 @@ ProcRRListProviderProperties(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 = (xRRListProviderPropertiesReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = bytes_to_int32(numProps * sizeof(Atom)), + .nAtoms = numProps + }; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); @@ -438,12 +440,14 @@ ProcRRQueryProviderProperty(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 = (xRRQueryProviderPropertyReply) { + .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); @@ -568,7 +572,10 @@ ProcRRGetProviderProperty(ClientPtr client) RRPropertyValuePtr prop_value; unsigned long n, len, ind; RRProviderPtr provider; - xRRGetProviderPropertyReply reply; + xRRGetProviderPropertyReply reply = { + .type = X_Reply, + .sequenceNumber = client->sequence + }; char *extra = NULL; REQUEST_SIZE_MATCH(xRRGetProviderPropertyReq); @@ -594,8 +601,6 @@ ProcRRGetProviderProperty(ClientPtr client) if (prop->propertyName == stuff->property) break; - reply.type = X_Reply; - reply.sequenceNumber = client->sequence; if (!prop) { reply.nItems = 0; reply.length = 0; diff --git a/randr/rrscreen.c b/randr/rrscreen.c index 6a7a08939..39340ccee 100644 --- a/randr/rrscreen.c +++ b/randr/rrscreen.c @@ -396,16 +396,17 @@ rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen) ErrorF("reporting %d %d %d %d\n", total_crtcs, total_outputs, total_modes, total_name_len); pScrPriv = rrGetScrPriv(pScreen); - rep.pad = 0; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.timestamp = pScrPriv->lastSetTime.milliseconds; - rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; - rep.nCrtcs = total_crtcs; - rep.nOutputs = total_outputs; - rep.nModes = total_modes; - rep.nbytesNames = total_name_len; + rep = (xRRGetScreenResourcesReply) { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0, + .timestamp = pScrPriv->lastSetTime.milliseconds, + .configTimestamp = pScrPriv->lastConfigTime.milliseconds, + .nCrtcs = total_crtcs, + .nOutputs = total_outputs, + .nModes = total_modes, + .nbytesNames = total_name_len + }; rep.length = (total_crtcs + total_outputs + total_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) + bytes_to_int32(rep.nbytesNames)); -- cgit v1.2.3 From a6c5b8d3ee053cadf685b0e4de96407ad6df4dd4 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 14 Jul 2012 10:50:41 -0700 Subject: Use C99 designated initializers in RandR 1.4 extension Events RandR 1.4 was going through review in parallel with main batch of C99 initialization changes - sync up now that both have landed. Signed-off-by: Alan Coopersmith Reviewed-by: Keith Packard --- randr/rrproviderproperty.c | 47 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/randr/rrproviderproperty.c b/randr/rrproviderproperty.c index 785f42c9a..e0a814ff8 100644 --- a/randr/rrproviderproperty.c +++ b/randr/rrproviderproperty.c @@ -65,14 +65,14 @@ RRDestroyProviderProperty(RRPropertyPtr prop) static void RRDeleteProperty(RRProviderRec * provider, RRPropertyRec * prop) { - xRRProviderPropertyNotifyEvent event; - - event.type = RREventBase + RRNotify; - event.subCode = RRNotify_ProviderProperty; - event.provider = provider->id; - event.state = PropertyDelete; - event.atom = prop->propertyName; - event.timestamp = currentTime.milliseconds; + xRRProviderPropertyNotifyEvent event = { + .type = RREventBase + RRNotify, + .subCode = RRNotify_ProviderProperty, + .provider = provider->id, + .state = PropertyDelete, + .atom = prop->propertyName, + .timestamp = currentTime.milliseconds + }; RRDeliverPropertyEvent(provider->pScreen, (xEvent *) &event); @@ -138,7 +138,6 @@ RRChangeProviderProperty(RRProviderPtr provider, Atom property, Atom type, pointer value, Bool sendevent, Bool pending) { RRPropertyPtr prop; - xRRProviderPropertyNotifyEvent event; rrScrPrivPtr pScrPriv = rrGetScrPriv(provider->pScreen); int size_in_bytes; int total_size; @@ -237,12 +236,14 @@ RRChangeProviderProperty(RRProviderPtr provider, Atom property, Atom type, provider->pendingProperties = TRUE; if (sendevent) { - event.type = RREventBase + RRNotify; - event.subCode = RRNotify_ProviderProperty; - event.provider = provider->id; - event.state = PropertyNewValue; - event.atom = prop->propertyName; - event.timestamp = currentTime.milliseconds; + xRRProviderPropertyNotifyEvent event = { + .type = RREventBase + RRNotify, + .subCode = RRNotify_ProviderProperty, + .provider = provider->id, + .state = PropertyNewValue, + .atom = prop->propertyName, + .timestamp = currentTime.milliseconds + }; RRDeliverPropertyEvent(provider->pScreen, (xEvent *) &event); } return Success; @@ -677,14 +678,14 @@ ProcRRGetProviderProperty(ClientPtr client) reply.propertyType = prop_value->type; if (stuff->delete && (reply.bytesAfter == 0)) { - xRRProviderPropertyNotifyEvent event; - - event.type = RREventBase + RRNotify; - event.subCode = RRNotify_ProviderProperty; - event.provider = provider->id; - event.state = PropertyDelete; - event.atom = prop->propertyName; - event.timestamp = currentTime.milliseconds; + xRRProviderPropertyNotifyEvent event = { + .type = RREventBase + RRNotify, + .subCode = RRNotify_ProviderProperty, + .provider = provider->id, + .state = PropertyDelete, + .atom = prop->propertyName, + .timestamp = currentTime.milliseconds + }; RRDeliverPropertyEvent(provider->pScreen, (xEvent *) &event); } -- cgit v1.2.3 From 6910280297ab610100dd8e7fbe5bb5cc08968f2f Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 14 Jul 2012 10:54:36 -0700 Subject: Use C99 designated initializers in DRI2GetParam replies DRI2GetParam was going through review in parallel with main batch of C99 initialization changes - sync up now that both have landed. Signed-off-by: Alan Coopersmith Reviewed-by: Keith Packard --- hw/xfree86/dri2/dri2ext.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c index eb6fd44fc..ee610c0ec 100644 --- a/hw/xfree86/dri2/dri2ext.c +++ b/hw/xfree86/dri2/dri2ext.c @@ -550,15 +550,16 @@ static int ProcDRI2GetParam(ClientPtr client) { REQUEST(xDRI2GetParamReq); - xDRI2GetParamReply rep; + xDRI2GetParamReply rep = { + .type = X_Reply, + .sequenceNumber = client->sequence, + .length = 0 + }; DrawablePtr pDrawable; CARD64 value; int status; REQUEST_SIZE_MATCH(xDRI2GetParamReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; if (!validDrawable(client, stuff->drawable, DixReadAccess, &pDrawable, &status)) -- cgit v1.2.3