CalmaRead.c: warning: variable 'libnameptr' is used uninitialized

The local variable 'libnameptr' is used from the 'goto done;' label cleanup
but it may not be initiailzied at the time of the first use of the label.

When evaluating this I also notice the global 'calmaErrorFile' when closed
does not have the handle invalidated.

CalmaRead.c:233:9: warning: variable 'libnameptr' is used uninitialized whenever 'if' condition is true
CalmaRead.c:231:9: warning: variable 'libnameptr' is used uninitialized whenever 'if' condition is true
CalmaRead.c:225:9: warning: variable 'libnameptr' is used uninitialized whenever 'if' condition is true

clang18 -Wall warning cleanup [-Wsometimes-uninitialized]
This commit is contained in:
Darryl L. Miles 2024-10-04 20:05:44 +01:00 committed by Tim Edwards
parent d5ef80acda
commit 95d3e9f85d
1 changed files with 6 additions and 2 deletions

View File

@ -172,7 +172,7 @@ CalmaReadFile(file, filename)
char *filename; /* The real name of the file read */
{
int k, version;
char *libname = NULL, *libnameptr;
char *libname = NULL, *libnameptr = NULL;
MagWindow *mw;
static int hdrSkip[] = { CALMA_FORMAT, CALMA_MASK, CALMA_ENDMASKS,
CALMA_REFLIBS, CALMA_FONTS, CALMA_ATTRTABLE,
@ -309,7 +309,11 @@ done:
HashKill(&calmaDefInitHash);
UndoEnable();
if (calmaErrorFile != NULL) fclose(calmaErrorFile);
if (calmaErrorFile != NULL)
{
fclose(calmaErrorFile);
calmaErrorFile = NULL;
}
}
/*