about summary refs log tree commit diff
path: root/third_party/nix/src/nix-daemon/nix-daemon.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/nix-daemon/nix-daemon.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/nix-daemon/nix-daemon.cc')
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon.cc34
1 files changed, 18 insertions, 16 deletions
diff --git a/third_party/nix/src/nix-daemon/nix-daemon.cc b/third_party/nix/src/nix-daemon/nix-daemon.cc
index 5a38e023fa..5b62d67dbe 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon.cc
@@ -115,7 +115,7 @@ struct TunnelLogger {
 
   /* stopWork() means that we're done; stop sending stderr to the
      client. */
-  void stopWork(bool success = true, const string& msg = "",
+  void stopWork(bool success = true, const std::string& msg = "",
                 unsigned int status = 0) {
     auto state(state_.lock());
 
@@ -175,7 +175,7 @@ struct TunnelSource : BufferedSource {
    the contents of the file to `s'.  Otherwise barf. */
 struct RetrieveRegularNARSink : ParseSink {
   bool regular{true};
-  string s;
+  std::string s;
 
   RetrieveRegularNARSink() {}
 
@@ -185,7 +185,7 @@ struct RetrieveRegularNARSink : ParseSink {
     s.append((const char*)data, len);
   }
 
-  void createSymlink(const Path& path, const string& target) override {
+  void createSymlink(const Path& path, const std::string& target) override {
     regular = false;
   }
 };
@@ -286,7 +286,7 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
     }
 
     case wopQueryPathFromHashPart: {
-      string hashPart = readString(from);
+      std::string hashPart = readString(from);
       logger->startWork();
       Path path = store->queryPathFromHashPart(hashPart);
       logger->stopWork();
@@ -340,8 +340,8 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
     }
 
     case wopAddTextToStore: {
-      string suffix = readString(from);
-      string s = readString(from);
+      std::string suffix = readString(from);
+      std::string s = readString(from);
       auto refs = readStorePaths<PathSet>(*store, from);
       logger->startWork();
       Path path = store->addTextToStore(suffix, s, refs, NoRepair);
@@ -505,8 +505,8 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
       if (GET_PROTOCOL_MINOR(clientVersion) >= 12) {
         unsigned int n = readInt(from);
         for (unsigned int i = 0; i < n; i++) {
-          string name = readString(from);
-          string value = readString(from);
+          std::string name = readString(from);
+          std::string value = readString(from);
           overrides.emplace(name, value);
         }
       }
@@ -855,7 +855,8 @@ static void setSigChldAction(bool autoReap) {
   }
 }
 
-bool matchUser(const string& user, const string& group, const Strings& users) {
+bool matchUser(const std::string& user, const std::string& group,
+               const Strings& users) {
   if (find(users.begin(), users.end(), "*") != users.end()) {
     return true;
   }
@@ -865,8 +866,8 @@ bool matchUser(const string& user, const string& group, const Strings& users) {
   }
 
   for (auto& i : users) {
-    if (string(i, 0, 1) == "@") {
-      if (group == string(i, 1)) {
+    if (std::string(i, 0, 1) == "@") {
+      if (group == std::string(i, 1)) {
         return true;
       }
       struct group* gr = getgrnam(i.c_str() + 1);
@@ -874,7 +875,7 @@ bool matchUser(const string& user, const string& group, const Strings& users) {
         continue;
       }
       for (char** mem = gr->gr_mem; *mem != nullptr; mem++) {
-        if (user == string(*mem)) {
+        if (user == std::string(*mem)) {
           return true;
         }
       }
@@ -953,7 +954,7 @@ static void daemonLoop(char** argv) {
       throw SysError("cannot create Unix domain socket");
     }
 
-    string socketPath = settings.nixDaemonSocketFile;
+    std::string socketPath = settings.nixDaemonSocketFile;
 
     createDirs(dirOf(socketPath));
 
@@ -1018,10 +1019,11 @@ static void daemonLoop(char** argv) {
       PeerInfo peer = getPeerInfo(remote.get());
 
       struct passwd* pw = peer.uidKnown ? getpwuid(peer.uid) : nullptr;
-      string user = pw != nullptr ? pw->pw_name : std::to_string(peer.uid);
+      std::string user = pw != nullptr ? pw->pw_name : std::to_string(peer.uid);
 
       struct group* gr = peer.gidKnown ? getgrgid(peer.gid) : nullptr;
-      string group = gr != nullptr ? gr->gr_name : std::to_string(peer.gid);
+      std::string group =
+          gr != nullptr ? gr->gr_name : std::to_string(peer.gid);
 
       Strings trustedUsers = settings.trustedUsers;
       Strings allowedUsers = settings.allowedUsers;
@@ -1062,7 +1064,7 @@ static void daemonLoop(char** argv) {
 
             /* For debugging, stuff the pid into argv[1]. */
             if (peer.pidKnown && (argv[1] != nullptr)) {
-              string processName = std::to_string(peer.pid);
+              std::string processName = std::to_string(peer.pid);
               strncpy(argv[1], processName.c_str(), strlen(argv[1]));
             }