about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/gc.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-24T21·29+0100
committerVincent Ambo <tazjin@google.com>2020-05-24T21·29+0100
commit838f86b0fd880b26539664140f04e5d16669dad8 (patch)
treec8fee2f0c136fbe5bb0735604e2f04d5b02698ba /third_party/nix/src/libstore/gc.cc
parentf30b2e610d9e612504a9f6460e0cc83413b80aeb (diff)
style(3p/nix): Remove 'using std::*' from types.hh r/840
It is considered bad form to use things from includes in headers, as
these directives propagate to everywhere else and can make it
confusing.

types.hh (which is includes almost literally everywhere) had some of
these directives, which this commit removes.
Diffstat (limited to 'third_party/nix/src/libstore/gc.cc')
-rw-r--r--third_party/nix/src/libstore/gc.cc38
1 files changed, 19 insertions, 19 deletions
diff --git a/third_party/nix/src/libstore/gc.cc b/third_party/nix/src/libstore/gc.cc
index bc3393265e48..1b2364c25383 100644
--- a/third_party/nix/src/libstore/gc.cc
+++ b/third_party/nix/src/libstore/gc.cc
@@ -20,8 +20,8 @@
 
 namespace nix {
 
-static string gcLockName = "gc.lock";
-static string gcRootsDir = "gcroots";
+static std::string gcLockName = "gc.lock";
+static std::string gcRootsDir = "gcroots";
 
 /* Acquire the global GC lock.  This is used to prevent new Nix
    processes from starting after the temporary root files have been
@@ -69,7 +69,7 @@ static void makeSymlink(const Path& link, const Path& target) {
 void LocalStore::syncWithGC() { AutoCloseFD fdGCLock = openGCLock(ltRead); }
 
 void LocalStore::addIndirectRoot(const Path& path) {
-  string hash = hashString(htSHA1, path).to_string(Base32, false);
+  std::string hash = hashString(htSHA1, path).to_string(Base32, false);
   Path realRoot = canonPath(
       (format("%1%/%2%/auto/%3%") % stateDir % gcRootsDir % hash).str());
   makeSymlink(realRoot, path);
@@ -105,7 +105,7 @@ Path LocalFSStore::addPermRoot(const Path& _storePath, const Path& _gcRoot,
       Path rootsDir =
           canonPath((format("%1%/%2%") % stateDir % gcRootsDir).str());
 
-      if (string(gcRoot, 0, rootsDir.size() + 1) != rootsDir + "/") {
+      if (std::string(gcRoot, 0, rootsDir.size() + 1) != rootsDir + "/") {
         throw Error(format("path '%1%' is not a valid garbage collector root; "
                            "it's not in the directory '%2%'") %
                     gcRoot % rootsDir);
@@ -184,7 +184,7 @@ void LocalStore::addTempRoot(const Path& path) {
   DLOG(INFO) << "acquiring write lock on " << fnTempRoots;
   lockFile(state->fdTempRoots.get(), ltWrite, true);
 
-  string s = path + '\0';
+  std::string s = path + '\0';
   writeFull(state->fdTempRoots.get(), s);
 
   /* Downgrade to a read lock. */
@@ -233,13 +233,13 @@ void LocalStore::findTempRoots(FDs& fds, Roots& tempRoots, bool censor) {
     lockFile(fd->get(), ltRead, true);
 
     /* Read the entire file. */
-    string contents = readFile(fd->get());
+    std::string contents = readFile(fd->get());
 
     /* Extract the roots. */
-    string::size_type pos = 0;
-    string::size_type end;
+    std::string::size_type pos = 0;
+    std::string::size_type end;
 
-    while ((end = contents.find((char)0, pos)) != string::npos) {
+    while ((end = contents.find((char)0, pos)) != std::string::npos) {
       Path root(contents, pos, end - pos);
       DLOG(INFO) << "got temporary root " << root;
       assertStorePath(root);
@@ -341,7 +341,7 @@ Roots LocalStore::findRoots(bool censor) {
   return roots;
 }
 
-static void readProcLink(const string& file, Roots& roots) {
+static void readProcLink(const std::string& file, Roots& roots) {
   /* 64 is the starting buffer size gnu readlink uses... */
   auto bufsiz = ssize_t{64};
 try_again:
@@ -365,7 +365,7 @@ try_again:
   }
 }
 
-static string quoteRegexChars(const string& raw) {
+static std::string quoteRegexChars(const std::string& raw) {
   static auto specialRegex = std::regex(R"([.^$\\*+?()\[\]{}|])");
   return std::regex_replace(raw, specialRegex, R"(\$&)");
 }
@@ -421,7 +421,7 @@ void LocalStore::findRuntimeRoots(Roots& roots, bool censor) {
 
         try {
           auto mapFile = fmt("/proc/%s/maps", ent->d_name);
-          auto mapLines = tokenizeString<std::vector<string>>(
+          auto mapLines = tokenizeString<std::vector<std::string>>(
               readFile(mapFile, true), "\n");
           for (const auto& line : mapLines) {
             auto match = std::smatch{};
@@ -458,7 +458,7 @@ void LocalStore::findRuntimeRoots(Roots& roots, bool censor) {
   if (getEnv("_NIX_TEST_NO_LSOF") == "") {
     try {
       std::regex lsofRegex(R"(^n(/.*)$)");
-      auto lsofLines = tokenizeString<std::vector<string>>(
+      auto lsofLines = tokenizeString<std::vector<std::string>>(
           runProgram(LSOF, true, {"-n", "-w", "-F", "n"}), "\n");
       for (const auto& line : lsofLines) {
         std::smatch match;
@@ -511,10 +511,10 @@ struct LocalStore::GCState {
 };
 
 bool LocalStore::isActiveTempFile(const GCState& state, const Path& path,
-                                  const string& suffix) {
+                                  const std::string& suffix) {
   return hasSuffix(path, suffix) &&
-         state.tempRoots.find(string(path, 0, path.size() - suffix.size())) !=
-             state.tempRoots.end();
+         state.tempRoots.find(std::string(
+             path, 0, path.size() - suffix.size())) != state.tempRoots.end();
 }
 
 void LocalStore::deleteGarbage(GCState& state, const Path& path) {
@@ -720,7 +720,7 @@ void LocalStore::removeUnusedLinks(const GCState& state) {
   struct dirent* dirent;
   while (errno = 0, dirent = readdir(dir.get())) {
     checkInterrupt();
-    string name = dirent->d_name;
+    std::string name = dirent->d_name;
     if (name == "." || name == "..") {
       continue;
     }
@@ -863,7 +863,7 @@ void LocalStore::collectGarbage(const GCOptions& options, GCResults& results) {
       struct dirent* dirent;
       while (errno = 0, dirent = readdir(dir.get())) {
         checkInterrupt();
-        string name = dirent->d_name;
+        std::string name = dirent->d_name;
         if (name == "." || name == "..") {
           continue;
         }
@@ -882,7 +882,7 @@ void LocalStore::collectGarbage(const GCOptions& options, GCResults& results) {
          less biased towards deleting paths that come
          alphabetically first (e.g. /nix/store/000...).  This
          matters when using --max-freed etc. */
-      vector<Path> entries_(entries.begin(), entries.end());
+      std::vector<Path> entries_(entries.begin(), entries.end());
       std::mt19937 gen(1);
       std::shuffle(entries_.begin(), entries_.end(), gen);