diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-10 11:38:04 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-11 14:35:34 -0800 |
commit | 64761ee9424f755b84ab0ce02d13eda32d215a14 (patch) | |
tree | 0d5369ba1460fb9c4be686511de659ed653362ba /parseutils.c | |
parent | 9737af15196380a1687d18a17d297ee17b45a83f (diff) |
Variable scope reductions
Some found by cppcheck, some found by manual code inspection
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'parseutils.c')
-rw-r--r-- | parseutils.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/parseutils.c b/parseutils.c index 4b77c4c..d779d76 100644 --- a/parseutils.c +++ b/parseutils.c @@ -420,7 +420,6 @@ ShapeDef * ShapeDeclCreate(Atom name, OutlineDef * outlines) { ShapeDef *shape; - OutlineDef *ol; shape = uTypedAlloc(ShapeDef); if (shape != NULL) @@ -432,7 +431,8 @@ ShapeDeclCreate(Atom name, OutlineDef * outlines) shape->name = name; shape->nOutlines = 0; shape->outlines = outlines; - for (ol = outlines; ol != NULL; ol = (OutlineDef *) ol->common.next) + for (OutlineDef *ol = outlines; ol != NULL; + ol = (OutlineDef *) ol->common.next) { if (ol->nPoints > 0) shape->nOutlines++; @@ -445,7 +445,6 @@ OutlineDef * OutlineCreate(Atom field, ExprDef * points) { OutlineDef *outline; - ExprDef *pt; outline = uTypedAlloc(OutlineDef); if (outline != NULL) @@ -457,7 +456,8 @@ OutlineCreate(Atom field, ExprDef * points) outline->nPoints = 0; if (points->op == ExprCoord) { - for (pt = points; pt != NULL; pt = (ExprDef *) pt->common.next) + for (ExprDef *pt = points; pt != NULL; + pt = (ExprDef *) pt->common.next) { outline->nPoints++; } @@ -500,7 +500,6 @@ RowDef * RowDeclCreate(KeyDef * keys) { RowDef *row; - KeyDef *key; row = uTypedAlloc(RowDef); if (row != NULL) @@ -510,7 +509,7 @@ RowDeclCreate(KeyDef * keys) row->common.next = NULL; row->nKeys = 0; row->keys = keys; - for (key = keys; key != NULL; key = (KeyDef *) key->common.next) + for (KeyDef *key = keys; key != NULL; key = (KeyDef *) key->common.next) { if (key->common.stmtType == StmtKeyDef) row->nKeys++; @@ -523,7 +522,6 @@ SectionDef * SectionDeclCreate(Atom name, RowDef * rows) { SectionDef *section; - RowDef *row; section = uTypedAlloc(SectionDef); if (section != NULL) @@ -534,7 +532,7 @@ SectionDeclCreate(Atom name, RowDef * rows) section->name = name; section->nRows = 0; section->rows = rows; - for (row = rows; row != NULL; row = (RowDef *) row->common.next) + for (RowDef *row = rows; row != NULL; row = (RowDef *) row->common.next) { if (row->common.stmtType == StmtRowDef) section->nRows++; @@ -565,7 +563,6 @@ OverlayDef * OverlayDeclCreate(Atom name, OverlayKeyDef * keys) { OverlayDef *ol; - OverlayKeyDef *key; ol = uTypedAlloc(OverlayDef); if (ol != NULL) @@ -574,7 +571,7 @@ OverlayDeclCreate(Atom name, OverlayKeyDef * keys) ol->common.stmtType = StmtOverlayDef; ol->name = name; ol->keys = keys; - for (key = keys; key != NULL; + for (OverlayKeyDef *key = keys; key != NULL; key = (OverlayKeyDef *) key->common.next) { ol->nKeys++; @@ -625,7 +622,6 @@ int LookupKeysym(const char *str, KeySym * sym_rtrn) { KeySym sym; - char *tmp; if ((!str) || (uStrCaseCmp(str, "any") == 0) || (uStrCaseCmp(str, "nosymbol") == 0)) @@ -646,6 +642,8 @@ LookupKeysym(const char *str, KeySym * sym_rtrn) return 1; } if (strlen(str) > 2 && str[0] == '0' && str[1] == 'x') { + char *tmp; + sym = strtoul(str, &tmp, 16); if (sym != ULONG_MAX && (!tmp || *tmp == '\0')) { *sym_rtrn = sym; @@ -762,10 +760,9 @@ PrintStmtAddrs(ParseCommon * stmt) static void CheckDefaultMap(XkbFile * maps) { - XkbFile *dflt, *tmp; + XkbFile *dflt = NULL; - dflt = NULL; - for (tmp = maps, dflt = NULL; tmp != NULL; + for (XkbFile *tmp = maps; tmp != NULL; tmp = (XkbFile *) tmp->common.next) { if (tmp->flags & XkbLC_Default) |