summaryrefslogtreecommitdiff
path: root/compat.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-10 11:38:04 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-11 14:35:34 -0800
commit64761ee9424f755b84ab0ce02d13eda32d215a14 (patch)
tree0d5369ba1460fb9c4be686511de659ed653362ba /compat.c
parent9737af15196380a1687d18a17d297ee17b45a83f (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 'compat.c')
-rw-r--r--compat.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/compat.c b/compat.c
index 92bd3c1..1902401 100644
--- a/compat.c
+++ b/compat.c
@@ -102,8 +102,6 @@ siText(SymInterpInfo * si, CompatInfo * info)
static void
InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
{
- int i;
-
info->xkb = xkb;
info->name = NULL;
info->fileID = 0;
@@ -117,7 +115,7 @@ InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
info->dflt.interp.flags = 0;
info->dflt.interp.virtual_mod = XkbNoModifier;
info->dflt.interp.act.type = XkbSA_NoAction;
- for (i = 0; i < XkbAnyActionDataSize; i++)
+ for (int i = 0; i < XkbAnyActionDataSize; i++)
{
info->dflt.interp.act.data[i] = 0;
}
@@ -135,8 +133,6 @@ InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
static void
ClearCompatInfo(CompatInfo * info, XkbDescPtr xkb)
{
- int i;
-
if (info->name != NULL)
uFree(info->name);
info->name = NULL;
@@ -145,7 +141,7 @@ ClearCompatInfo(CompatInfo * info, XkbDescPtr xkb)
info->dflt.interp.flags = 0;
info->dflt.interp.virtual_mod = XkbNoModifier;
info->dflt.interp.act.type = XkbSA_NoAction;
- for (i = 0; i < XkbAnyActionDataSize; i++)
+ for (int i = 0; i < XkbAnyActionDataSize; i++)
{
info->dflt.interp.act.data[i] = 0;
}
@@ -198,13 +194,13 @@ FindMatchingInterp(CompatInfo * info, SymInterpInfo * new)
static Bool
AddInterp(CompatInfo * info, SymInterpInfo * new)
{
- unsigned collide;
SymInterpInfo *old;
- collide = 0;
old = FindMatchingInterp(info, new);
if (old != NULL)
{
+ unsigned collide = 0;
+
if (new->defs.merge == MergeReplace)
{
SymInterpInfo *next = (SymInterpInfo *) old->defs.next;
@@ -349,8 +345,7 @@ ResolveStateAndPredicate(ExprDef * expr,
static void
MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
{
- SymInterpInfo *si;
- LEDInfo *led, *rtrn, *next;
+ LEDInfo *next;
GroupCompatInfo *gcm;
int i;
@@ -364,7 +359,8 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
into->name = from->name;
from->name = NULL;
}
- for (si = from->interps; si; si = (SymInterpInfo *) si->defs.next)
+ for (SymInterpInfo *si = from->interps; si;
+ si = (SymInterpInfo *) si->defs.next)
{
if (merge != MergeDefault)
si->defs.merge = merge;
@@ -378,8 +374,10 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
if (!AddGroupCompat(into, i, gcm))
into->errorCount++;
}
- for (led = from->leds; led != NULL; led = next)
+ for (LEDInfo *led = from->leds; led != NULL; led = next)
{
+ LEDInfo *rtrn;
+
next = (LEDInfo *) led->defs.next;
if (merge != MergeDefault)
led->defs.merge = merge;
@@ -794,9 +792,8 @@ static void
CopyInterps(CompatInfo * info,
XkbCompatMapPtr compat, Bool needSymbol, unsigned pred)
{
- SymInterpInfo *si;
-
- for (si = info->interps; si; si = (SymInterpInfo *) si->defs.next)
+ for (SymInterpInfo *si = info->interps; si;
+ si = (SymInterpInfo *) si->defs.next)
{
if (((si->interp.match & XkbSI_OpMask) != pred) ||
(needSymbol && (si->interp.sym == NoSymbol)) ||
@@ -817,10 +814,8 @@ Bool
CompileCompatMap(XkbFile * file,
XkbFileInfo * result, unsigned merge, LEDInfo ** unboundLEDs)
{
- int i;
CompatInfo info;
XkbDescPtr xkb;
- GroupCompatInfo *gcm;
xkb = result->xkb;
InitCompatInfo(&info, xkb);
@@ -830,7 +825,9 @@ CompileCompatMap(XkbFile * file,
if (info.errorCount == 0)
{
- int size;
+ int size, i;
+ GroupCompatInfo *gcm;
+
if (XkbAllocCompatMap(xkb, XkbAllCompatMask, info.nInterps) !=
Success)
{