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 /hw/kdrive | |
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 'hw/kdrive')
-rw-r--r-- | hw/kdrive/ephyr/ephyrdriext.c | 14 | ||||
-rw-r--r-- | hw/kdrive/ephyr/ephyrglxext.c | 4 |
2 files changed, 11 insertions, 7 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; diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c index 1287e0484..f5c4c181f 100644 --- a/hw/kdrive/ephyr/ephyrglxext.c +++ b/hw/kdrive/ephyr/ephyrglxext.c @@ -512,6 +512,7 @@ ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap) xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc; xGLXMakeCurrentReply reply; DrawablePtr drawable = NULL; + GLXContextTag contextTag = 0; int rc = 0; EPHYR_LOG("enter\n"); @@ -525,13 +526,14 @@ ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap) if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawable->pScreen->myNum), req->context, req->oldContextTag, - (int *) &reply.contextTag)) { + (int *) &contextTag)) { EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n"); goto out; } reply.length = 0; reply.type = X_Reply; reply.sequenceNumber = a_cl->client->sequence; + reply.contextTag = contextTag; if (a_do_swap) { __GLX_DECLARE_SWAP_VARIABLES; __GLX_SWAP_SHORT(&reply.sequenceNumber); |