From 95d3e9f85d75daa5d402d70a2e7b9bf965eaee70 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Fri, 4 Oct 2024 20:05:44 +0100 Subject: [PATCH] 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] --- calma/CalmaRead.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/calma/CalmaRead.c b/calma/CalmaRead.c index 08b0c0b6..04919c02 100644 --- a/calma/CalmaRead.c +++ b/calma/CalmaRead.c @@ -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; + } } /*