diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-07-09 19:12:42 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-07-09 19:14:50 -0700 |
commit | 5b86c072d1d586ce040d8831a05cf97ff8b17821 (patch) | |
tree | 0652f715c003f9c61044b09a288d235ff92d81f3 /dix | |
parent | c2fb1a7b2ab58d70b38ee03ab2fdeb4e7183a356 (diff) |
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 <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Tested-by: Daniel Stone <daniel@fooishbar.org>
Diffstat (limited to 'dix')
-rw-r--r-- | dix/dispatch.c | 18 | ||||
-rw-r--r-- | dix/events.c | 15 |
2 files changed, 22 insertions, 11 deletions
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); diff --git a/dix/events.c b/dix/events.c index 6e4385a16..c5eceec93 100644 --- a/dix/events.c +++ b/dix/events.c @@ -4797,6 +4797,7 @@ ProcGrabPointer(ClientPtr client) GrabMask mask; WindowPtr confineTo; CursorPtr oldCursor; + BYTE status; REQUEST(xGrabPointerReq); int rc; @@ -4818,7 +4819,6 @@ ProcGrabPointer(ClientPtr client) return rc; } - memset(&rep, 0, sizeof(xGrabPointerReply)); oldCursor = NullCursor; grab = device->deviceGrab.grab; @@ -4833,14 +4833,16 @@ ProcGrabPointer(ClientPtr client) rc = GrabDevice(client, device, stuff->pointerMode, stuff->keyboardMode, stuff->grabWindow, stuff->ownerEvents, stuff->time, - &mask, CORE, stuff->cursor, stuff->confineTo, &rep.status); + &mask, CORE, stuff->cursor, stuff->confineTo, &status); if (rc != Success) return rc; - if (oldCursor && rep.status == GrabSuccess) + if (oldCursor && status == GrabSuccess) FreeCursor(oldCursor, (Cursor) 0); + memset(&rep, 0, sizeof(xGrabPointerReply)); rep.type = X_Reply; + rep.status = status; rep.sequenceNumber = client->sequence; rep.length = 0; WriteReplyToClient(client, sizeof(xGrabPointerReply), &rep); @@ -5059,6 +5061,7 @@ int ProcGrabKeyboard(ClientPtr client) { xGrabKeyboardReply rep; + BYTE status; REQUEST(xGrabKeyboardReq); int result; @@ -5067,17 +5070,19 @@ ProcGrabKeyboard(ClientPtr client) REQUEST_SIZE_MATCH(xGrabKeyboardReq); - memset(&rep, 0, sizeof(xGrabKeyboardReply)); mask.core = KeyPressMask | KeyReleaseMask; result = GrabDevice(client, keyboard, stuff->pointerMode, stuff->keyboardMode, stuff->grabWindow, stuff->ownerEvents, stuff->time, &mask, CORE, None, - None, &rep.status); + None, &status); if (result != Success) return result; + + memset(&rep, 0, sizeof(xGrabKeyboardReply)); rep.type = X_Reply; + rep.status = status; rep.sequenceNumber = client->sequence; rep.length = 0; WriteReplyToClient(client, sizeof(xGrabKeyboardReply), &rep); |