From 9401b6694597a3d9912bf673a3b090e70199e08b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 19 Oct 2017 11:50:34 +0300 Subject: [PATCH] db: complain if we can't open the schema files I feel like that's reasonable, to require that the schema files are present. Signed-off-by: Dan Carpenter --- smatch_db.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/smatch_db.c b/smatch_db.c index 43033a2d..beda3f01 100644 --- a/smatch_db.c +++ b/smatch_db.c @@ -1896,13 +1896,19 @@ static void init_memdb(void) for (i = 0; i < ARRAY_SIZE(schema_files); i++) { fd = open_data_file(schema_files[i]); if (fd < 0) { - mem_db = NULL; - return; + printf("failed to open: %s\n", schema_files[i]); + continue; } ret = read(fd, buf, sizeof(buf)); + if (ret < 0) { + printf("failed to read: %s\n", schema_files[i]); + continue; + } + close(fd); if (ret == sizeof(buf)) { printf("Schema file too large: %s (limit %zd bytes)", schema_files[i], sizeof(buf)); + continue; } buf[ret] = '\0'; rc = sqlite3_exec(mem_db, buf, NULL, NULL, &err); -- 2.11.4.GIT