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 --- dix/dispatch.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'dix/dispatch.c') diff --git a/dix/dispatch.c b/dix/dispatch.c index 4231cb0ac..787f87f72 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -2801,17 +2801,21 @@ ProcLookupColor(ClientPtr client) rc = dixLookupResourceByType((pointer *) &pcmp, stuff->cmap, RT_COLORMAP, client, DixReadAccess); if (rc == Success) { - xLookupColorReply lcr; + CARD16 exactRed, exactGreen, exactBlue; if (OsLookupColor (pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes, - &lcr.exactRed, &lcr.exactGreen, &lcr.exactBlue)) { + &exactRed, &exactGreen, &exactBlue)) { + xLookupColorReply lcr; lcr.type = X_Reply; lcr.length = 0; lcr.sequenceNumber = client->sequence; - lcr.screenRed = lcr.exactRed; - lcr.screenGreen = lcr.exactGreen; - lcr.screenBlue = lcr.exactBlue; + lcr.exactRed = exactRed; + lcr.exactGreen = exactGreen; + lcr.exactBlue = exactBlue; + lcr.screenRed = exactRed; + lcr.screenGreen = exactGreen; + lcr.screenBlue = exactBlue; (*pcmp->pScreen->ResolveColor) (&lcr.screenRed, &lcr.screenGreen, &lcr.screenBlue, pcmp->pVisual); @@ -3109,6 +3113,7 @@ ProcListHosts(ClientPtr client) { xListHostsReply reply; int len, nHosts, result; + BOOL enabled; pointer pdata; /* REQUEST(xListHostsReq); */ @@ -3120,10 +3125,11 @@ ProcListHosts(ClientPtr client) if (result != Success) return result; - result = GetHosts(&pdata, &nHosts, &len, &reply.enabled); + result = GetHosts(&pdata, &nHosts, &len, &enabled); if (result != Success) return result; reply.type = X_Reply; + reply.enabled = enabled; reply.sequenceNumber = client->sequence; reply.nHosts = nHosts; reply.length = bytes_to_int32(len); -- cgit v1.2.3