about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/nar-info-disk-cache.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-20T03·33+0100
committerVincent Ambo <tazjin@google.com>2020-05-20T03·33+0100
commitd331d3a0b5c497a46e2636f308234be66566c04c (patch)
tree92526b2f99456c09c5cc81233ed5a4311abe3d2b /third_party/nix/src/libstore/nar-info-disk-cache.cc
parentfed31b2c9b364fc1ed0b724c21b068cdedf46ee7 (diff)
refactor(3p/nix): Apply clang-tidy's modernize-* fixes r/787
This applies the modernization fixes listed here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html

The 'modernize-use-trailing-return-type' fix was excluded due to my
personal preference (more specifically, I think the 'auto' keyword is
misleading in that position).
Diffstat (limited to 'third_party/nix/src/libstore/nar-info-disk-cache.cc')
-rw-r--r--third_party/nix/src/libstore/nar-info-disk-cache.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/third_party/nix/src/libstore/nar-info-disk-cache.cc b/third_party/nix/src/libstore/nar-info-disk-cache.cc
index 3adda508d081..7ef178ab4388 100644
--- a/third_party/nix/src/libstore/nar-info-disk-cache.cc
+++ b/third_party/nix/src/libstore/nar-info-disk-cache.cc
@@ -116,7 +116,7 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache {
 
     /* Periodically purge expired entries from the database. */
     retrySQLite<void>([&]() {
-      auto now = time(0);
+      auto now = time(nullptr);
 
       SQLiteStmt queryLastPurge(state->db, "select value from LastPurge");
       auto queryLastPurge_(queryLastPurge.use());
@@ -157,7 +157,8 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache {
 
       // FIXME: race
 
-      state->insertCache.use()(uri)(time(0))(storeDir)(wantMassQuery)(priority)
+      state->insertCache
+          .use()(uri)(time(nullptr))(storeDir)(wantMassQuery)(priority)
           .exec();
       assert(sqlite3_changes(state->db) == 1);
       state->caches[uri] = Cache{(int)sqlite3_last_insert_rowid(state->db),
@@ -198,18 +199,18 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache {
 
           auto& cache(getCache(*state, uri));
 
-          auto now = time(0);
+          auto now = time(nullptr);
 
           auto queryNAR(state->queryNAR.use()(cache.id)(hashPart)(
               now - settings.ttlNegativeNarInfoCache)(
               now - settings.ttlPositiveNarInfoCache));
 
           if (!queryNAR.next()) {
-            return {oUnknown, 0};
+            return {oUnknown, nullptr};
           }
 
           if (!queryNAR.getInt(0)) {
-            return {oInvalid, 0};
+            return {oInvalid, nullptr};
           }
 
           auto narInfo = make_ref<NarInfo>();
@@ -254,21 +255,22 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache {
 
         state->insertNAR
             .use()(cache.id)(hashPart)(storePathToName(info->path))(
-                narInfo ? narInfo->url : "", narInfo != 0)(
-                narInfo ? narInfo->compression : "", narInfo != 0)(
+                narInfo ? narInfo->url : "", narInfo != nullptr)(
+                narInfo ? narInfo->compression : "", narInfo != nullptr)(
                 narInfo && narInfo->fileHash ? narInfo->fileHash.to_string()
                                              : "",
                 narInfo && narInfo->fileHash)(
                 narInfo ? narInfo->fileSize : 0,
-                narInfo != 0 && narInfo->fileSize)(info->narHash.to_string())(
+                narInfo != nullptr &&
+                    narInfo->fileSize)(info->narHash.to_string())(
                 info->narSize)(concatStringsSep(" ", info->shortRefs()))(
                 info->deriver != "" ? baseNameOf(info->deriver) : "",
-                info->deriver !=
-                    "")(concatStringsSep(" ", info->sigs))(info->ca)(time(0))
+                info->deriver != "")(concatStringsSep(" ", info->sigs))(
+                info->ca)(time(nullptr))
             .exec();
 
       } else {
-        state->insertMissingNAR.use()(cache.id)(hashPart)(time(0)).exec();
+        state->insertMissingNAR.use()(cache.id)(hashPart)(time(nullptr)).exec();
       }
     });
   }