diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-19T16·38+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-19T16·38+0100 |
commit | b490742a511dd03afc43f5143d6d61edaeeb8091 (patch) | |
tree | 727370e8e7607a3078c2ce1cd6d717105c7d9c44 /third_party/nix/src/libstore/local-store.cc | |
parent | c758de9d22506eb279c5abe61f621e5c8f61af95 (diff) |
style(3p/nix): Enforce braces around loops and conditionals r/767
This change was generated with: fd -e cc -e hh | xargs -I{} clang-tidy {} -p ~/projects/nix-build/ \ --checks='-*,readability-braces-around-statements' --fix \ -fix-errors Some manual fixes were applied because some convoluted unbraced statements couldn't be untangled by clang-tidy. This commit still includes invalid files, but I decided to clean them up in a subsequent commit so that it becomes more obvious where clang-tidy failed. Maybe this will allow for a bug-report to clang-tidy.
Diffstat (limited to 'third_party/nix/src/libstore/local-store.cc')
-rw-r--r-- | third_party/nix/src/libstore/local-store.cc | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/third_party/nix/src/libstore/local-store.cc b/third_party/nix/src/libstore/local-store.cc index 4c57c8a32a2b..1e49ab88c260 100644 --- a/third_party/nix/src/libstore/local-store.cc +++ b/third_party/nix/src/libstore/local-store.cc @@ -157,19 +157,17 @@ LocalStore::LocalStore(const Params& params) /* Check the current database schema and if necessary do an upgrade. */ int curSchema = getSchema(); - if (curSchema > nixSchemaVersion) + if (curSchema > nixSchemaVersion) { throw Error( format( "current Nix store schema is version %1%, but I only support %2%") % curSchema % nixSchemaVersion); - else if (curSchema == 0) { /* new store */ + } else if (curSchema == 0) { /* new store */ curSchema = nixSchemaVersion; openDB(*state, true); writeFile(schemaPath, (format("%1%") % nixSchemaVersion).str()); - } - - else if (curSchema < nixSchemaVersion) { + } else if (curSchema < nixSchemaVersion) { if (curSchema < 5) throw Error( "Your Nix store has a database in Berkeley DB format,\n" @@ -219,10 +217,9 @@ LocalStore::LocalStore(const Params& params) writeFile(schemaPath, (format("%1%") % nixSchemaVersion).str()); lockFile(globalLock.get(), ltRead, true); - } - - else + } else { openDB(*state, false); + } /* Prepare SQL statements. */ state->stmtRegisterValidPath.create( @@ -325,8 +322,9 @@ void LocalStore::openDB(State& state, bool create) { SetDllDirectoryW(L""); #endif - if (sqlite3_busy_timeout(db, 60 * 60 * 1000) != SQLITE_OK) + if (sqlite3_busy_timeout(db, 60 * 60 * 1000) != SQLITE_OK) { throwSQLiteError(db, "setting timeout"); + } db.exec("pragma foreign_keys = 1"); @@ -347,8 +345,9 @@ void LocalStore::openDB(State& state, bool create) { { SQLiteStmt stmt; stmt.create(db, "pragma main.journal_mode;"); - if (sqlite3_step(stmt) != SQLITE_ROW) + if (sqlite3_step(stmt) != SQLITE_ROW) { throwSQLiteError(db, "querying journal mode"); + } prevMode = string((const char*)sqlite3_column_text(stmt, 0)); } if (prevMode != mode && @@ -622,7 +621,9 @@ uint64_t LocalStore::addValidPath(State& state, const ValidPathInfo& info, derivations). Note that if this throws an error, then the DB transaction is rolled back, so the path validity registration above is undone. */ - if (checkOutputs) checkDerivationOutputs(info.path, drv); + if (checkOutputs) { + checkDerivationOutputs(info.path, drv); + } for (auto& i : drv.outputs) { state.stmtAddDerivationOutput.use()(id)(i.first)(i.second.path).exec(); @@ -1046,8 +1047,9 @@ Path LocalStore::addToStoreFromDump(const string& dump, const string& name, if (recursive) { StringSource source(dump); restorePath(realPath, source); - } else + } else { writeFile(realPath, dump); + } canonicalisePathMetaData(realPath, -1); @@ -1059,8 +1061,9 @@ Path LocalStore::addToStoreFromDump(const string& dump, const string& name, if (recursive) { hash.first = hashAlgo == htSHA256 ? h : hashString(htSHA256, dump); hash.second = dump.size(); - } else + } else { hash = hashPath(htSHA256, realPath); + } optimisePath(realPath); // FIXME: combine with hashPath() @@ -1297,14 +1300,16 @@ void LocalStore::verifyPath(const Path& path, const PathSet& store, } else { LOG(ERROR) << "path '" << path << "' disappeared, but it still has valid referrers!"; - if (repair) try { + if (repair) { + try { repairPath(path); } catch (Error& e) { LOG(WARNING) << e.msg(); errors = true; } - else + } else { errors = true; + } } return; |