From afc015217221acd8667a96111b147f3a742a2c4e Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 18 Aug 2022 19:12:42 -0700 Subject: Variable scope reductions as suggested by cppcheck Signed-off-by: Alan Coopersmith --- src/XRecord.c | 12 ++++++------ 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; rnreqType = 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--; -- cgit v1.2.1