summaryrefslogtreecommitdiff
path: root/hw/kdrive/ephyr/ephyrdriext.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 /hw/kdrive/ephyr/ephyrdriext.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 'hw/kdrive/ephyr/ephyrdriext.c')
-rw-r--r--hw/kdrive/ephyr/ephyrdriext.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index aefbcfbce..65e0ff8fe 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -586,6 +586,7 @@ ProcXF86DRIOpenConnection(register ClientPtr client)
xXF86DRIOpenConnectionReply rep;
drm_handle_t hSAREA;
char *busIdString = NULL;
+ CARD32 busIdStringLength = 0;
REQUEST(xXF86DRIOpenConnectionReq);
REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
@@ -600,15 +601,16 @@ ProcXF86DRIOpenConnection(register ClientPtr client)
return BadValue;
}
+ if (busIdString)
+ busIdStringLength = strlen(busIdString);
+
rep.type = X_Reply;
rep.sequenceNumber = client->sequence;
- rep.busIdStringLength = 0;
- if (busIdString)
- rep.busIdStringLength = strlen(busIdString);
+ rep.busIdStringLength = busIdStringLength;
rep.length =
bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) -
SIZEOF(xGenericReply) +
- pad_to_int32(rep.busIdStringLength));
+ pad_to_int32(busIdStringLength));
rep.hSAREALow = (CARD32) (hSAREA & 0xffffffff);
#if defined(LONG64) && !defined(__linux__)
@@ -618,8 +620,8 @@ ProcXF86DRIOpenConnection(register ClientPtr client)
#endif
WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), &rep);
- if (rep.busIdStringLength)
- WriteToClient(client, rep.busIdStringLength, busIdString);
+ if (busIdStringLength)
+ WriteToClient(client, busIdStringLength, busIdString);
free(busIdString);
EPHYR_LOG("leave\n");
return Success;