summaryrefslogtreecommitdiff
path: root/dix/events.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-09 19:12:42 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-07-09 19:14:50 -0700
commit5b86c072d1d586ce040d8831a05cf97ff8b17821 (patch)
tree0652f715c003f9c61044b09a288d235ff92d81f3 /dix/events.c
parentc2fb1a7b2ab58d70b38ee03ab2fdeb4e7183a356 (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/events.c')
-rw-r--r--dix/events.c15
1 files changed, 10 insertions, 5 deletions
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);