[PATCH:imake 1/2] Avoid closing inFile twice in CheckImakefileC if LogFatal returns

Alan Coopersmith alan.coopersmith at oracle.com
Sat Aug 25 11:37:45 PDT 2012


Imake's LogFatal() checks if it's being re-entered and if so, returns,
so we can't mark it NORETURN, leading to static analyzers believing it
can return even in call paths it shouldn't.

Resolves warning from Parfait 1.0.1:
Error: File Invalid
   File not Initialized: The value inFile is not initialized as a file.
        at line 748 of imake.c in function 'CheckImakefileC'.
          inFile initialized at line 738 with fopen(masterc, "r").
          inFile destroyed at line 745 with fclose(inFile).

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 imake.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/imake.c b/imake.c
index 1cb8388..2ca34c3 100644
--- a/imake.c
+++ b/imake.c
@@ -745,7 +745,8 @@ CheckImakefileC(const char *masterc)
 			fclose(inFile);
 			LogFatal("Refuse to overwrite: %s", masterc);
 		}
-		fclose(inFile);
+		else
+			fclose(inFile);
 	}
 }
 
-- 
1.7.9.2



More information about the xorg-devel mailing list