From 4bbc62129724cdc61f601e4f1c98490bca403619 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 31 May 2014 19:18:08 -0700 Subject: Move some local variables to the scope in which they live Helps both human readers and static code analyzers realize they're not used outside these scopes. Flagged by cppcheck 1.64: [psgeom.c:1761]: (style) The scope of the variable 'keycode' can be reduced. [psgeom.c:1858]: (style) The scope of the variable 'len' can be reduced. Signed-off-by: Alan Coopersmith --- psgeom.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'psgeom.c') diff --git a/psgeom.c b/psgeom.c index 135f7ec..b72b250 100644 --- a/psgeom.c +++ b/psgeom.c @@ -1758,7 +1758,6 @@ static void PSLabelKey(FILE *out, PSState *state, KeyTop *top, int x, int y, XkbBoundsPtr bounds, int kc, int btm) { - char keycode[10]; int w, h, i; int row_y[3]; int col_x[3]; @@ -1855,10 +1854,10 @@ PSLabelKey(FILE *out, PSState *state, KeyTop *top, int x, int y, } for (i = 0; i < NLABELS; i++) { if (present[i]) { - int len, size; + int size; if (top->size[i] == SZ_AUTO) { - len = strlen(top->label[i]); + int len = strlen(top->label[i]); if (len == 1) { if (top->font[i] == FONT_ISOCAPS) size = 18; @@ -1887,6 +1886,8 @@ PSLabelKey(FILE *out, PSState *state, KeyTop *top, int x, int y, } } if (state->args->wantKeycodes) { + char keycode[10]; + snprintf(keycode, sizeof(keycode), "%d", kc); PSSetFont(out, state, FONT_LATIN1, 8, True); PSDrawLabel(out, keycode, x + bounds->x1, y + btm - 5, w, 0); -- cgit v1.2.3