temporary hack to solve crashing bug in fs/reiserfs/journal.o
[smatch.git] / smatch_db.c
blob8e96872c14986ee57d96f8e5d8f5a4ee1ff74a7d
1 /*
2 * smatch/smatch_db.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include <string.h>
11 #include <sqlite3.h>
12 #include "smatch.h"
13 #include "smatch_extra.h"
15 static sqlite3 *db;
17 void sql_exec(int (*callback)(void*, int, char**, char**), const char *sql)
19 char *err = NULL;
20 int rc;
22 if (option_no_db || !db)
23 return;
25 rc = sqlite3_exec(db, sql, callback, 0, &err);
26 if (rc != SQLITE_OK) {
27 fprintf(stderr, "SQL error #2: %s\n", err);
28 exit(1);
32 void open_smatch_db(void)
34 int rc;
36 if (option_no_db)
37 return;
39 rc = sqlite3_open_v2("smatch_db.sqlite", &db, SQLITE_OPEN_READONLY, NULL);
40 if (rc != SQLITE_OK)
41 option_no_db = 1;