summaryrefslogtreecommitdiff
path: root/listing.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 /listing.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 'listing.c')
-rw-r--r--listing.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/listing.c b/listing.c
index 4c8fe70..92246e2 100644
--- a/listing.c
+++ b/listing.c
@@ -400,13 +400,11 @@ AddMatchingFiles(char *head_in)
static Bool
MapMatches(char *mapToConsider, char *ptrn)
{
- int i;
-
if (ptrn != NULL)
return XkbNameMatchesPattern(mapToConsider, ptrn);
if (nMapOnly < 1)
return True;
- for (i = 0; i < nMapOnly; i++)
+ for (int i = 0; i < nMapOnly; i++)
{
if (XkbNameMatchesPattern(mapToConsider, mapOnly[i]))
return True;
@@ -417,11 +415,8 @@ MapMatches(char *mapToConsider, char *ptrn)
int
GenerateListing(char *out_name)
{
- int i;
- FILE *inputFile, *outFile;
- XkbFile *rtrn, *mapToUse;
- unsigned oldWarningLevel;
- char *mapName;
+ FILE *outFile;
+ XkbFile *rtrn;
if (nFilesListed < 1)
{
@@ -441,8 +436,9 @@ GenerateListing(char *out_name)
if (warningLevel > 9)
fprintf(stderr, "should list:\n");
#endif
- for (i = 0; i < nListed; i++)
+ for (int i = 0; i < nListed; i++)
{
+ unsigned oldWarningLevel;
#ifdef DEBUG
if (warningLevel > 9)
{
@@ -455,6 +451,7 @@ GenerateListing(char *out_name)
warningLevel = 0;
if (list[i].file)
{
+ FILE *inputFile;
struct stat sbuf;
if (stat(list[i].file, &sbuf) < 0)
@@ -480,8 +477,8 @@ GenerateListing(char *out_name)
setScanState(list[i].file, 1);
if (XKBParseFile(inputFile, &rtrn) && (rtrn != NULL))
{
- mapName = list[i].map;
- mapToUse = rtrn;
+ char *mapName = list[i].map;
+ XkbFile *mapToUse = rtrn;
for (; mapToUse; mapToUse = (XkbFile *) mapToUse->common.next)
{
if (!MapMatches(mapToUse->name, mapName))