From: Otto Moerbeek Date: Mon, 4 May 2020 09:00:23 +0000 (+0200) Subject: Apply suggestions from code review X-Git-Tag: dnsdist-1.5.0-rc2~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5c2ec49817a7b80cf20e78e1933f39c6183c3e2;p=thirdparty%2Fpdns.git Apply suggestions from code review Co-authored-by: Remi Gacogne --- diff --git a/pdns/ssqlite3.cc b/pdns/ssqlite3.cc index e35b7fb9d0..b36a256e6b 100644 --- a/pdns/ssqlite3.cc +++ b/pdns/ssqlite3.cc @@ -235,26 +235,26 @@ std::unique_ptr SSQLite3::prepare(const string& query, int nparam void SSQLite3::execute(const string& query) { char *errmsg; std::string errstr1; - int rc = sqlite3_exec(m_pDB, query.c_str(), NULL, NULL, &errmsg); - if (rc != 0) { + int rc = sqlite3_exec(m_pDB, query.c_str(), nullptr, nullptr, &errmsg); + if (rc != SQLITE_OK) { errstr1 = errmsg; sqlite3_free(errmsg); } if (rc == SQLITE_BUSY) { if (m_in_transaction) { - throw("Failed to execute query: " + errstr1); + throw SSqlException("Failed to execute query: " + errstr1); } else { rc = sqlite3_exec(m_pDB, query.c_str(), NULL, NULL, &errmsg); std::string errstr2; - if (rc != 0) { + if (rc != SQLITE_OK) { errstr2 = errmsg; sqlite3_free(errmsg); } if (rc != SQLITE_OK && rc != SQLITE_DONE && rc != SQLITE_ROW) { - throw("Failed to execute query: " + errstr2); + throw SSqlException("Failed to execute query: " + errstr2); } } - } else if (rc != 0) { + } else if (rc != SQLITE_OK) { throw("Failed to execute query: " + errstr1); } }