summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-31 19:18:08 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-31 19:18:08 -0700
commit4bbc62129724cdc61f601e4f1c98490bca403619 (patch)
treed4128abc7fb27d0fd139137f5fffc16acf0c3066
parent7d186165440c5a370af7551f5958baae2f0b3725 (diff)
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 <alan.coopersmith@oracle.com>
-rw-r--r--psgeom.c7
1 files changed, 4 insertions, 3 deletions
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);