From eafede5a3d9120c2be9f8b3365cf78164fa2a852 Mon Sep 17 00:00:00 2001 From: Mark Watts Date: Fri, 10 Oct 2014 11:45:33 -0500 Subject: [PATCH 1/2] Fixed one problem --- fc2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fc2.c b/fc2.c index 6f9d8e2..a82a23c 100644 --- a/fc2.c +++ b/fc2.c @@ -111,7 +111,7 @@ GList *_sqlite_getfile_stmt(FileCabinet *fc, file_id_t key) int status; GList *res = NULL; - while ((status = sqlite3_step(stmt)) == SQLITE_OK) + while ((status = sqlite3_step(stmt)) == SQLITE_ROW) { int id = sqlite3_column_int(stmt, 0); /* get the actual file */ From 6ee0022a0060cd28fb9161ae89c3607c71e5eb92 Mon Sep 17 00:00:00 2001 From: Mark Watts Date: Fri, 10 Oct 2014 12:05:55 -0500 Subject: [PATCH 2/2] Formatting and more informative message on tagdb_new failure --- fc2.c | 3 ++- tagdb.c | 8 ++++---- tests/acceptance_test.pl | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/fc2.c b/fc2.c index a82a23c..3193546 100644 --- a/fc2.c +++ b/fc2.c @@ -121,7 +121,8 @@ GList *_sqlite_getfile_stmt(FileCabinet *fc, file_id_t key) if (status != SQLITE_DONE) { - error("We didn't finish the getfile SQLite statemnt for some reason."); + const char* msg = sqlite3_errmsg(fc->sqlitedb); + error("We didn't finish the getfile SQLite statemnt:%s(%d)", msg, status); } return res; } diff --git a/tagdb.c b/tagdb.c index c39ba07..85e6102 100644 --- a/tagdb.c +++ b/tagdb.c @@ -409,13 +409,13 @@ TagDB *tagdb_new0 (char *db_fname, int flags) /* new file statement */ sqlite3_prepare_v2(db->sqldb, "insert into file(id,name) values(?,?)", -1, &STMT(db,NEWFIL), NULL); /* delete tag statement */ - sqlite3_prepare_v2(db->sqldb, "delete from tag where id = ?", -1, &STMT(db,DELTAG), NULL); + sqlite3_prepare_v2(db->sqldb, "delete from tag where id=?", -1, &STMT(db,DELTAG), NULL); /* delete file statement */ - sqlite3_prepare_v2(db->sqldb, "delete from file where id = ?", -1, &STMT(db,DELFIL), NULL); + sqlite3_prepare_v2(db->sqldb, "delete from file where id=?", -1, &STMT(db,DELFIL), NULL); /* rename file statement */ - sqlite3_prepare_v2(db->sqldb, "update or ignore file set name = ? where id = ?", -1, &STMT(db,RENFIL), NULL); + sqlite3_prepare_v2(db->sqldb, "update or ignore file set name=? where id=?", -1, &STMT(db,RENFIL), NULL); /* rename tag statement */ - sqlite3_prepare_v2(db->sqldb, "update or ignore tag set name = ? where id = ?", -1, &STMT(db,RENTAG), NULL); + sqlite3_prepare_v2(db->sqldb, "update or ignore tag set name=? where id=?", -1, &STMT(db,RENTAG), NULL); db->files = file_cabinet_new_sqlite(db->sqldb); file_cabinet_new_drawer(db->files, UNTAGGED); diff --git a/tests/acceptance_test.pl b/tests/acceptance_test.pl index 1182d4c..b571adf 100755 --- a/tests/acceptance_test.pl +++ b/tests/acceptance_test.pl @@ -19,8 +19,8 @@ sub setupTestDir $dataDirName = make_data_dir(); # Have to create this before the fork so that it's shared - $VALGRIND_OUTPUT = `mktemp /tmp/acctest-valgrind.out.XXX`; - $TAGFS_LOG = `mktemp /tmp/acctest-tagfs-log.out.XXX`; + $VALGRIND_OUTPUT = `mktemp /tmp/acctest-valgrind.out.XXXXXX`; + $TAGFS_LOG = `mktemp /tmp/acctest-tagfs-log.out.XXXXXX`; chomp $VALGRIND_OUTPUT; chomp $TAGFS_LOG; @@ -59,7 +59,7 @@ sub make_data_dir sub make_tempdir { my $tail = shift; - my $s = `mktemp -d /tmp/acctest-tagfs-${tail}XXX`; + my $s = `mktemp -d /tmp/acctest-tagfs-${tail}XXXXXX`; chomp $s; if (not (-d $s)) {