From 122fa8689837bc5a5166432609f351c200a17ef6 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 16 Oct 2022 10:58:05 -0700 Subject: Variable scope reductions as recommended by cppcheck Signed-off-by: Alan Coopersmith --- grid.c | 7 +++---- xfd.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/grid.c b/grid.c index f844d37..fc3b272 100644 --- a/grid.c +++ b/grid.c @@ -169,10 +169,9 @@ GridFirstChar (Widget w) FcChar32 map[FC_CHARSET_MAP_SIZE]; FcChar32 next; FcChar32 first; - int i; first = FcCharSetFirstPage (xft->charset, map, &next); - for (i = 0; i < FC_CHARSET_MAP_SIZE; i++) + for (int i = 0; i < FC_CHARSET_MAP_SIZE; i++) if (map[i]) { FcChar32 bits = map[i]; @@ -207,12 +206,12 @@ GridLastChar (Widget w) { FcChar32 this, last, next; FcChar32 map[FC_CHARSET_MAP_SIZE]; - int i; + last = FcCharSetFirstPage (xft->charset, map, &next); while ((this = FcCharSetNextPage (xft->charset, map, &next)) != FC_CHARSET_DONE) last = this; last &= ~0xff; - for (i = FC_CHARSET_MAP_SIZE - 1; i >= 0; i--) + for (int i = FC_CHARSET_MAP_SIZE - 1; i >= 0; i--) if (map[i]) { FcChar32 bits = map[i]; diff --git a/xfd.c b/xfd.c index c339acf..14f0e4a 100644 --- a/xfd.c +++ b/xfd.c @@ -431,7 +431,6 @@ change_page(int page) { long oldstart, newstart; int ncols, nrows; - char buf[256]; Arg arg; arg.name = XtNstartChar; @@ -453,6 +452,7 @@ change_page(int page) if (!page || newstart != oldstart) { unsigned int row = (unsigned int) ((newstart >> 8)); unsigned int col = (unsigned int) (newstart & 0xff); + char buf[256]; XtSetArg (arg, XtNlabel, buf); snprintf (buf, sizeof(buf), xfd_resources.start_format, -- cgit v1.2.3