refactor(3p/nix): Apply clang-tidy's readability-* fixes

This applies the readability fixes listed here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html
This commit is contained in:
Vincent Ambo 2020-05-20 22:27:37 +01:00
parent d331d3a0b5
commit 689ef502f5
78 changed files with 863 additions and 792 deletions

View file

@ -14,7 +14,7 @@ namespace nix {
int exterr = sqlite3_extended_errcode(db);
auto path = sqlite3_db_filename(db, nullptr);
if (!path) {
if (path == nullptr) {
path = "(in-memory)";
}
@ -23,9 +23,8 @@ namespace nix {
err == SQLITE_PROTOCOL
? fmt("SQLite database '%s' is busy (SQLITE_PROTOCOL)", path)
: fmt("SQLite database '%s' is busy", path));
} else {
throw SQLiteError("%s: %s (in '%s')", fs.s, sqlite3_errstr(exterr), path);
}
throw SQLiteError("%s: %s (in '%s')", fs.s, sqlite3_errstr(exterr), path);
}
SQLite::SQLite(const Path& path) {
@ -38,7 +37,7 @@ SQLite::SQLite(const Path& path) {
SQLite::~SQLite() {
try {
if (db && sqlite3_close(db) != SQLITE_OK) {
if ((db != nullptr) && sqlite3_close(db) != SQLITE_OK) {
throwSQLiteError(db, "closing database");
}
} catch (...) {
@ -67,7 +66,7 @@ void SQLiteStmt::create(sqlite3* db, const string& sql) {
SQLiteStmt::~SQLiteStmt() {
try {
if (stmt && sqlite3_finalize(stmt) != SQLITE_OK) {
if ((stmt != nullptr) && sqlite3_finalize(stmt) != SQLITE_OK) {
throwSQLiteError(db, fmt("finalizing statement '%s'", sql));
}
} catch (...) {