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 /action.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 'action.c')
-rw-r--r-- | action.c | 62 |
1 files changed, 41 insertions, 21 deletions
@@ -396,8 +396,6 @@ HandleSetLatchMods(XkbDescPtr xkb, unsigned field, ExprDef * array_ndx, ExprDef * value) { XkbModAction *act; - unsigned rtrn; - unsigned t1, t2; act = (XkbModAction *) action; if (array_ndx != NULL) @@ -414,15 +412,18 @@ HandleSetLatchMods(XkbDescPtr xkb, { case F_ClearLocks: case F_LatchToLock: - rtrn = act->flags; + { + unsigned rtrn = act->flags; if (CheckLatchLockFlags(action->type, field, value, &rtrn)) { act->flags = rtrn; return True; } return False; + } case F_Modifiers: - t1 = act->flags; + { + unsigned t1 = act->flags, t2; if (CheckModifierField(xkb, action->type, value, &t1, &t2)) { act->flags = t1; @@ -433,6 +434,7 @@ HandleSetLatchMods(XkbDescPtr xkb, } return False; } + } return ReportIllegal(action->type, field); } @@ -450,8 +452,6 @@ HandleLockMods(XkbDescPtr xkb, unsigned field, ExprDef * array_ndx, ExprDef * value) { XkbModAction *act; - unsigned t1, t2; - ExprResult rtrn; act = (XkbModAction *) action; if ((array_ndx != NULL) && (field == F_Modifiers || field == F_Affect)) @@ -459,13 +459,17 @@ HandleLockMods(XkbDescPtr xkb, switch (field) { case F_Affect: + { + ExprResult rtrn; if (!ExprResolveEnum(value, &rtrn, lockWhich)) return ReportMismatch(action->type, field, "lock or unlock"); act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock); act->flags |= rtrn.uval; return True; + } case F_Modifiers: - t1 = act->flags; + { + unsigned t1 = act->flags, t2; if (CheckModifierField(xkb, action->type, value, &t1, &t2)) { act->flags = t1; @@ -476,6 +480,7 @@ HandleLockMods(XkbDescPtr xkb, } return False; } + } return ReportIllegal(action->type, field); } @@ -534,9 +539,6 @@ HandleSetLatchGroup(XkbDescPtr xkb, unsigned field, ExprDef * array_ndx, ExprDef * value) { XkbGroupAction *act; - unsigned rtrn; - unsigned t1; - int t2; act = (XkbGroupAction *) action; if (array_ndx != NULL) @@ -553,15 +555,19 @@ HandleSetLatchGroup(XkbDescPtr xkb, { case F_ClearLocks: case F_LatchToLock: - rtrn = act->flags; + { + unsigned rtrn = act->flags; if (CheckLatchLockFlags(action->type, field, value, &rtrn)) { act->flags = rtrn; return True; } return False; + } case F_Group: - t1 = act->flags; + { + unsigned t1 = act->flags; + int t2; if (CheckGroupField(action->type, value, &t1, &t2)) { act->flags = t1; @@ -570,6 +576,7 @@ HandleSetLatchGroup(XkbDescPtr xkb, } return False; } + } return ReportIllegal(action->type, field); } @@ -579,15 +586,14 @@ HandleLockGroup(XkbDescPtr xkb, unsigned field, ExprDef * array_ndx, ExprDef * value) { XkbGroupAction *act; - unsigned t1; - int t2; act = (XkbGroupAction *) action; if ((array_ndx != NULL) && (field == F_Group)) return ReportActionNotArray(action->type, field); if (field == F_Group) { - t1 = act->flags; + unsigned t1 = act->flags; + int t2; if (CheckGroupField(action->type, value, &t1, &t2)) { act->flags = t1; @@ -606,7 +612,6 @@ HandleMovePtr(XkbDescPtr xkb, { ExprResult rtrn; XkbPtrAction *act; - Bool absolute; act = (XkbPtrAction *) action; if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y))) @@ -614,6 +619,8 @@ HandleMovePtr(XkbDescPtr xkb, if ((field == F_X) || (field == F_Y)) { + Bool absolute; + if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) absolute = False; else @@ -803,13 +810,14 @@ HandleISOLock(XkbDescPtr xkb, { ExprResult rtrn; XkbISOAction *act; - unsigned flags, mods; - int group; + unsigned flags; act = (XkbISOAction *) action; switch (field) { case F_Modifiers: + { + unsigned mods; if (array_ndx != NULL) return ReportActionNotArray(action->type, field); flags = act->flags; @@ -822,7 +830,10 @@ HandleISOLock(XkbDescPtr xkb, return True; } return False; + } case F_Group: + { + int group; if (array_ndx != NULL) return ReportActionNotArray(action->type, field); flags = act->flags; @@ -833,6 +844,7 @@ HandleISOLock(XkbDescPtr xkb, return True; } return False; + } case F_Affect: if (array_ndx != NULL) return ReportActionNotArray(action->type, field); @@ -1064,8 +1076,6 @@ HandleRedirectKey(XkbDescPtr xkb, { ExprResult rtrn; XkbRedirectKeyAction *act; - unsigned t1, t2, vmods, vmask; - unsigned long tmp; if (array_ndx != NULL) return ReportActionNotArray(action->type, field); @@ -1074,6 +1084,10 @@ HandleRedirectKey(XkbDescPtr xkb, switch (field) { case F_Keycode: + { + unsigned int t1; + unsigned long tmp; + if (!ExprResolveKeyName(value, &rtrn, NULL, NULL)) return ReportMismatch(action->type, field, "key name"); tmp = KeyNameToLong(rtrn.keyName.name); @@ -1085,11 +1099,16 @@ HandleRedirectKey(XkbDescPtr xkb, } act->new_key = t1; return True; + } case F_ModsToClear: case F_Modifiers: - t1 = 0; + { + unsigned t1 = 0, t2; + if (CheckModifierField(xkb, action->type, value, &t1, &t2)) { + unsigned vmods, vmask; + act->mods_mask |= (t2 & 0xff); if (field == F_Modifiers) act->mods |= (t2 & 0xff); @@ -1110,6 +1129,7 @@ HandleRedirectKey(XkbDescPtr xkb, } return True; } + } return ReportIllegal(action->type, field); } |