From 5b86c072d1d586ce040d8831a05cf97ff8b17821 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 9 Jul 2012 19:12:42 -0700 Subject: Use temporary variables instead of parts of reply structures When passing variable pointers to functions or otherwise doing long sequences to compute values for replies, create & use some new temporary variables, to allow for simpler initialization of reply structures in the following patches. Move memsets & other initializations to group with the rest of the filling in of the reply structure, now that they're not needed so early in the code path. Signed-off-by: Alan Coopersmith Reviewed-by: Keith Packard Tested-by: Daniel Stone --- record/record.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'record') diff --git a/record/record.c b/record/record.c index a3ee4dd3d..54a0e68dd 100644 --- a/record/record.c +++ b/record/record.c @@ -2135,6 +2135,7 @@ ProcRecordGetContext(ClientPtr client) GetContextRangeInfoPtr pri; int i; int err; + CARD32 nClients, length; REQUEST_SIZE_MATCH(xRecordGetContextReq); VERIFY_CONTEXT(pContext, stuff->context, client); @@ -2218,12 +2219,12 @@ ProcRecordGetContext(ClientPtr client) /* calculate number of clients and reply length */ - rep.nClients = 0; - rep.length = 0; + nClients = 0; + length = 0; for (pRCAP = pContext->pListOfRCAP, pri = pRangeInfo; pRCAP; pRCAP = pRCAP->pNextRCAP, pri++) { - rep.nClients += pRCAP->numClients; - rep.length += pRCAP->numClients * + nClients += pRCAP->numClients; + length += pRCAP->numClients * (bytes_to_int32(sizeof(xRecordClientInfo)) + pri->nRanges * bytes_to_int32(sizeof(xRecordRange))); } @@ -2232,8 +2233,10 @@ ProcRecordGetContext(ClientPtr client) rep.type = X_Reply; rep.sequenceNumber = client->sequence; + rep.length = length; rep.enabled = pContext->pRecordingClient != NULL; rep.elementHeader = pContext->elemHeaders; + rep.nClients = nClients; if (client->swapped) { swaps(&rep.sequenceNumber); swapl(&rep.length); -- cgit v1.2.3