From c83f446412ecdb5f8521068988a92a63d6a5c1f2 Mon Sep 17 00:00:00 2001 From: Henrik Nilsson Date: Tue, 15 Dec 2009 13:28:26 +0100 Subject: [PATCH] cppcheck doesn't always report a filename for an error. Added some error checking so this tool doesn't crash. --- htmlreport/cppcheck-htmlreport | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htmlreport/cppcheck-htmlreport b/htmlreport/cppcheck-htmlreport index 5bb7f552d..4c50ee53a 100755 --- a/htmlreport/cppcheck-htmlreport +++ b/htmlreport/cppcheck-htmlreport @@ -161,6 +161,8 @@ class CppCheckHandler(XmlContentHandler): if name != "error": return + if attributes["file"] == "": + sys.stderr.write("ERROR: cppcheck error reported without a file name.\n") self.errors.append( { "file" : attributes["file"], @@ -233,6 +235,9 @@ if __name__ == '__main__': lines.append(error["line"]) source_file = os.path.join(source_dir, filename) + if not os.path.isfile(source_file): + sys.stderr.write("ERROR: Source file '%s' not found.\n" % source_file) + continue stream = file(source_file) content = stream.read() stream.close()