diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-08-18 19:12:42 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-08-18 19:12:42 -0700 |
commit | afc015217221acd8667a96111b147f3a742a2c4e (patch) | |
tree | 27045d1bc7703f0c3c3d3b5d6cbf45e53ecc4f92 | |
parent | ff3456b04e1b42fd77e0db061bf7a563108b5868 (diff) |
Variable scope reductions as suggested by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/XRecord.c | 12 | ||||
-rw-r--r-- | src/XTest.c | 9 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/XRecord.c b/src/XRecord.c index 00f4480..9a655cb 100644 --- a/src/XRecord.c +++ b/src/XRecord.c @@ -409,7 +409,7 @@ XRecordGetContext(Display *dpy, XRecordContext context, XExtDisplayInfo *info = find_display (dpy); register xRecordGetContextReq *req; xRecordGetContextReply rep; - unsigned int count, i, rn; + unsigned int count; xRecordRange xrange; xRecordClientInfo xclient_inf; XRecordState *ret; @@ -459,7 +459,7 @@ XRecordGetContext(Display *dpy, XRecordContext context, SyncHandle(); return 0; } - for(i = 0; i < count; i++) + for (unsigned int i = 0; i < count; i++) { client_inf[i] = &(client_inf_str[i]); _XRead(dpy, (char *)&xclient_inf, (long)sizeof(xRecordClientInfo)); @@ -487,7 +487,7 @@ XRecordGetContext(Display *dpy, XRecordContext context, SyncHandle(); return 0; } - for (rn=0; rn<xclient_inf.nRanges; rn++) { + for (unsigned int rn = 0; rn < xclient_inf.nRanges; rn++) { client_inf_str[i].ranges[rn] = &(ranges[rn]); _XRead(dpy, (char *)&xrange, (long)sizeof(xRecordRange)); WireToLibRange(&xrange, &(ranges[rn])); @@ -727,12 +727,11 @@ parse_reply_call_callback( { unsigned int current_index; int datum_bytes = 0; - XRecordInterceptData *data; /* call the callback for each protocol element in the reply */ current_index = 0; do { - data = alloc_inter_data(info); + XRecordInterceptData *data = alloc_inter_data(info); if (!data) return Error; @@ -870,7 +869,6 @@ XRecordEnableContext(Display *dpy, XRecordContext context, register xRecordEnableContextReq *req; xRecordEnableContextReply rep; struct reply_buffer *reply; - enum parser_return status; XRecordCheckExtension (dpy, info, 0); LockDisplay(dpy); @@ -882,6 +880,8 @@ XRecordEnableContext(Display *dpy, XRecordContext context, while (1) { + enum parser_return status; + /* This code should match that in XRecordEnableContextAsync */ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) { diff --git a/src/XTest.c b/src/XTest.c index e534ee4..2e53700 100644 --- a/src/XTest.c +++ b/src/XTest.c @@ -99,10 +99,11 @@ XTestQueryExtension (Display *dpy, int *major_return, int *minor_return) { XExtDisplayInfo *info = find_display (dpy); - register xXTestGetVersionReq *req; xXTestGetVersionReply rep; if (XextHasExtension(info)) { + xXTestGetVersionReq *req; + LockDisplay(dpy); GetReq(XTestGetVersion, req); req->reqType = info->codes->major_opcode; @@ -259,7 +260,6 @@ send_axes( int n_axes) { deviceValuator ev; - int n; req->deviceid |= MORE_EVENTS; req->length += ((n_axes + 5) / 6) * (SIZEOF(xEvent) >> 2); @@ -267,7 +267,7 @@ send_axes( ev.deviceid = dev->device_id; ev.first_valuator = first_axis; while (n_axes > 0) { - n = n_axes > 6 ? 6 : n_axes; + int n = n_axes > 6 ? 6 : n_axes; ev.num_valuators = n; switch (n) { case 6: @@ -433,11 +433,10 @@ Status XTestDiscard(Display *dpy) { Bool something; - register char *ptr; LockDisplay(dpy); if ((something = (dpy->bufptr != dpy->buffer))) { - for (ptr = dpy->buffer; + for (char *ptr = dpy->buffer; ptr < dpy->bufptr; ptr += (((xReq *)ptr)->length << 2)) dpy->request--; |