diff mbox

[2/2] xenstore: add assertion in database dumping code

Message ID 1469024022-6505-3-git-send-email-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu July 20, 2016, 2:13 p.m. UTC
If memfile is NULL, the signal handler won't be installed, hence fopen
won't dereference NULL. Coverity is not smart enough to figure that out
unfortunately.

Add an assertion to prevent coverity from complaining.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
---
 tools/xenstore/xenstored_core.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Ian Jackson July 20, 2016, 2:24 p.m. UTC | #1
Wei Liu writes ("[PATCH 2/2] xenstore: add assertion in database dumping code"):
> If memfile is NULL, the signal handler won't be installed, hence fopen
> won't dereference NULL. Coverity is not smart enough to figure that out
> unfortunately.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff mbox

Patch

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 5b2a49b..693d47d 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -2135,6 +2135,7 @@  int main(int argc, char *argv[])
 		if (trigger_talloc_report) {
 			FILE *out;
 
+			assert(memfile);
 			trigger_talloc_report = false;
 			out = fopen(memfile, "a");
 			if (out) {