summaryrefslogtreecommitdiff
path: root/keycodes.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 /keycodes.c
parent9737af15196380a1687d18a17d297ee17b45a83f (diff)
downloadxorg-app-xkbcomp-64761ee9424f755b84ab0ce02d13eda32d215a14.tar.gz
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 'keycodes.c')
-rw-r--r--keycodes.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/keycodes.c b/keycodes.c
index d4b9b5c..6ec4435 100644
--- a/keycodes.c
+++ b/keycodes.c
@@ -130,9 +130,7 @@ NextIndicatorName(KeyNamesInfo * info)
static IndicatorNameInfo *
FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
{
- IndicatorNameInfo *old;
-
- for (old = info->leds; old != NULL;
+ for (IndicatorNameInfo *old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next)
{
if (old->ndx == ndx)
@@ -144,9 +142,7 @@ FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
static IndicatorNameInfo *
FindIndicatorByName(KeyNamesInfo * info, Atom name)
{
- IndicatorNameInfo *old;
-
- for (old = info->leds; old != NULL;
+ for (IndicatorNameInfo *old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next)
{
if (old->name == name)
@@ -200,9 +196,7 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
info->leds = (IndicatorNameInfo *) old->defs.next;
else
{
- IndicatorNameInfo *tmp;
- tmp = info->leds;
- for (; tmp != NULL;
+ for (IndicatorNameInfo *tmp = info->leds; tmp != NULL;
tmp = (IndicatorNameInfo *) tmp->defs.next)
{
if (tmp->defs.next == (CommonInfo *) old)
@@ -307,9 +301,7 @@ InitKeyNamesInfo(KeyNamesInfo * info)
static int
FindKeyByLong(KeyNamesInfo * info, unsigned long name)
{
- int i;
-
- for (i = info->effectiveMin; i <= info->effectiveMax; i++)
+ for (int i = info->effectiveMin; i <= info->effectiveMax; i++)
{
if (info->names[i] == name)
return i;
@@ -435,9 +427,6 @@ static void
MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
unsigned merge)
{
- int i;
- char buf[5];
-
if (from->errorCount > 0)
{
into->errorCount += from->errorCount;
@@ -448,9 +437,11 @@ MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
into->name = from->name;
from->name = NULL;
}
- for (i = from->computedMin; i <= from->computedMax; i++)
+ for (int i = from->computedMin; i <= from->computedMax; i++)
{
unsigned thisMerge;
+ char buf[5];
+
if (from->names[i] == 0)
continue;
LongToKeyName(from->names[i], buf);
@@ -540,11 +531,10 @@ HandleIncludeKeycodes(IncludeStmt * stmt, XkbDescPtr xkb, KeyNamesInfo * info)
/* Do we have more than one include statement? */
if ((stmt->next != NULL) && (included.errorCount < 1))
{
- IncludeStmt *next;
unsigned op;
KeyNamesInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next)
+ for (IncludeStmt *next = stmt->next; next != NULL; next = next->next)
{
if ((next->file == NULL) && (next->map == NULL))
{