From bcbfd00eba9b06d07e240d087acacc68db2d5828 Mon Sep 17 00:00:00 2001 From: Christophe Le Roy Date: Sat, 8 Oct 2016 21:09:52 +0200 Subject: [PATCH] DBSQLite3: Do not raise in destructor Throwing exception from destructor is not recommended and generates lots of warnings during compilation. Don't use macro SQLRES, and: - ignore return code of sqlite3_finalize (of no interest here) - log to stderr sqlite3_close failure --- db-sqlite3.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db-sqlite3.cpp b/db-sqlite3.cpp index b7416f3..eb87d1a 100644 --- a/db-sqlite3.cpp +++ b/db-sqlite3.cpp @@ -1,5 +1,6 @@ #include #include // for usleep +#include #include "db-sqlite3.h" #include "types.h" @@ -31,11 +32,12 @@ DBSQLite3::DBSQLite3(const std::string &mapdir) DBSQLite3::~DBSQLite3() { - int result; - SQLOK(finalize(stmt_get_blocks_z)); - SQLOK(finalize(stmt_get_block_pos)); + sqlite3_finalize(stmt_get_blocks_z); + sqlite3_finalize(stmt_get_block_pos); - SQLOK(close(db)); + if (sqlite3_close(db) != SQLITE_OK) { + std::cerr << "Error closing SQLite database." << std::endl; + }; } std::vector DBSQLite3::getBlockPos()