about summary refs log tree commit diff
path: root/third_party/nix/src/nix
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/nix')
-rw-r--r--third_party/nix/src/nix/command.cc9
-rw-r--r--third_party/nix/src/nix/command.hh2
-rw-r--r--third_party/nix/src/nix/installables.cc12
-rw-r--r--third_party/nix/src/nix/legacy.cc2
-rw-r--r--third_party/nix/src/nix/log.cc2
-rw-r--r--third_party/nix/src/nix/main.cc2
-rw-r--r--third_party/nix/src/nix/optimise-store.cc2
-rw-r--r--third_party/nix/src/nix/repl.cc8
-rw-r--r--third_party/nix/src/nix/run.cc11
-rw-r--r--third_party/nix/src/nix/search.cc5
-rw-r--r--third_party/nix/src/nix/show-config.cc2
11 files changed, 31 insertions, 26 deletions
diff --git a/third_party/nix/src/nix/command.cc b/third_party/nix/src/nix/command.cc
index b35fb1be98..b0efcb823d 100644
--- a/third_party/nix/src/nix/command.cc
+++ b/third_party/nix/src/nix/command.cc
@@ -1,11 +1,13 @@
 #include "command.hh"
 
+#include <utility>
+
 #include "derivations.hh"
 #include "store-api.hh"
 
 namespace nix {
 
-Commands* RegisterCommand::commands = 0;
+Commands* RegisterCommand::commands = nullptr;
 
 void Command::printHelp(const string& programName, std::ostream& out) {
   Args::printHelp(programName, out);
@@ -22,7 +24,8 @@ void Command::printHelp(const string& programName, std::ostream& out) {
   }
 }
 
-MultiCommand::MultiCommand(const Commands& _commands) : commands(_commands) {
+MultiCommand::MultiCommand(Commands _commands)
+    : commands(std::move(_commands)) {
   expectedArgs.push_back(ExpectedArg{
       "command", 1, true, [=](std::vector<std::string> ss) {
         assert(!command);
@@ -82,7 +85,7 @@ bool MultiCommand::processArgs(const Strings& args, bool finish) {
   }
 }
 
-StoreCommand::StoreCommand() {}
+StoreCommand::StoreCommand() = default;
 
 ref<Store> StoreCommand::getStore() {
   if (!_store) {
diff --git a/third_party/nix/src/nix/command.hh b/third_party/nix/src/nix/command.hh
index a86f478213..829ce080d3 100644
--- a/third_party/nix/src/nix/command.hh
+++ b/third_party/nix/src/nix/command.hh
@@ -149,7 +149,7 @@ class MultiCommand : virtual Args {
 
   std::shared_ptr<Command> command;
 
-  MultiCommand(const Commands& commands);
+  MultiCommand(Commands commands);
 
   void printHelp(const string& programName, std::ostream& out) override;
 
diff --git a/third_party/nix/src/nix/installables.cc b/third_party/nix/src/nix/installables.cc
index 2d896e3bb9..06419f1f12 100644
--- a/third_party/nix/src/nix/installables.cc
+++ b/third_party/nix/src/nix/installables.cc
@@ -1,4 +1,5 @@
 #include <regex>
+#include <utility>
 
 #include "attr-path.hh"
 #include "command.hh"
@@ -100,7 +101,8 @@ Buildable Installable::toBuildable() {
 struct InstallableStorePath : Installable {
   Path storePath;
 
-  explicit InstallableStorePath(const Path& storePath) : storePath(storePath) {}
+  explicit InstallableStorePath(Path storePath)
+      : storePath(std::move(storePath)) {}
 
   std::string what() override { return storePath; }
 
@@ -160,8 +162,8 @@ struct InstallableValue : Installable {
 struct InstallableExpr : InstallableValue {
   std::string text;
 
-  InstallableExpr(SourceExprCommand& cmd, const std::string& text)
-      : InstallableValue(cmd), text(text) {}
+  InstallableExpr(SourceExprCommand& cmd, std::string text)
+      : InstallableValue(cmd), text(std::move(text)) {}
 
   std::string what() override { return text; }
 
@@ -175,8 +177,8 @@ struct InstallableExpr : InstallableValue {
 struct InstallableAttrPath : InstallableValue {
   std::string attrPath;
 
-  InstallableAttrPath(SourceExprCommand& cmd, const std::string& attrPath)
-      : InstallableValue(cmd), attrPath(attrPath) {}
+  InstallableAttrPath(SourceExprCommand& cmd, std::string attrPath)
+      : InstallableValue(cmd), attrPath(std::move(attrPath)) {}
 
   std::string what() override { return attrPath; }
 
diff --git a/third_party/nix/src/nix/legacy.cc b/third_party/nix/src/nix/legacy.cc
index 2860afe53a..b851392b42 100644
--- a/third_party/nix/src/nix/legacy.cc
+++ b/third_party/nix/src/nix/legacy.cc
@@ -2,6 +2,6 @@
 
 namespace nix {
 
-RegisterLegacyCommand::Commands* RegisterLegacyCommand::commands = 0;
+RegisterLegacyCommand::Commands* RegisterLegacyCommand::commands = nullptr;
 
 }
diff --git a/third_party/nix/src/nix/log.cc b/third_party/nix/src/nix/log.cc
index 29107bbdcd..86f133e94a 100644
--- a/third_party/nix/src/nix/log.cc
+++ b/third_party/nix/src/nix/log.cc
@@ -8,7 +8,7 @@
 using namespace nix;
 
 struct CmdLog : InstallableCommand {
-  CmdLog() {}
+  CmdLog() = default;
 
   std::string name() override { return "log"; }
 
diff --git a/third_party/nix/src/nix/main.cc b/third_party/nix/src/nix/main.cc
index 23bc62887a..54285bfa93 100644
--- a/third_party/nix/src/nix/main.cc
+++ b/third_party/nix/src/nix/main.cc
@@ -179,7 +179,7 @@ void mainWrapped(int argc, char** argv) {
 }  // namespace nix
 
 int main(int argc, char* argv[]) {
-  FLAGS_logtostderr = 1;
+  FLAGS_logtostderr = true;
   google::InitGoogleLogging(argv[0]);
 
   return nix::handleExceptions(argv[0],
diff --git a/third_party/nix/src/nix/optimise-store.cc b/third_party/nix/src/nix/optimise-store.cc
index 7814a1bcab..5fdcfb7424 100644
--- a/third_party/nix/src/nix/optimise-store.cc
+++ b/third_party/nix/src/nix/optimise-store.cc
@@ -7,7 +7,7 @@
 using namespace nix;
 
 struct CmdOptimiseStore : StoreCommand {
-  CmdOptimiseStore() {}
+  CmdOptimiseStore() = default;
 
   std::string name() override { return "optimise-store"; }
 
diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc
index 80921f77dc..9567ad4315 100644
--- a/third_party/nix/src/nix/repl.cc
+++ b/third_party/nix/src/nix/repl.cc
@@ -1,10 +1,10 @@
 #include <climits>
+#include <csetjmp>
 #include <cstdlib>
 #include <cstring>
 #include <iostream>
 
 #include <glog/logging.h>
-#include <setjmp.h>
 
 #ifdef READLINE
 #include <readline/history.h>
@@ -73,7 +73,7 @@ struct NixRepl {
   Expr* parseString(string s);
   void evalString(string s, Value& v);
 
-  typedef set<Value*> ValuesSeen;
+  using ValuesSeen = set<Value*>;
   std::ostream& printValue(std::ostream& str, Value& v, unsigned int maxDepth);
   std::ostream& printValue(std::ostream& str, Value& v, unsigned int maxDepth,
                            ValuesSeen& seen);
@@ -306,7 +306,7 @@ bool NixRepl::getLine(string& input, const std::string& prompt) {
       throw SysError("restoring signals");
     }
 
-    if (sigaction(SIGINT, &old, 0)) {
+    if (sigaction(SIGINT, &old, nullptr)) {
       throw SysError("restoring handler for SIGINT");
     }
   };
@@ -358,7 +358,7 @@ StringSet NixRepl::completePrefix(string prefix) {
     }
   } else if ((dot = cur.rfind('.')) == string::npos) {
     /* This is a variable name; look it up in the current scope. */
-    StringSet::iterator i = varNames.lower_bound(cur);
+    auto i = varNames.lower_bound(cur);
     while (i != varNames.end()) {
       if (string(*i, 0, cur.size()) != cur) {
         break;
diff --git a/third_party/nix/src/nix/run.cc b/third_party/nix/src/nix/run.cc
index 523aa87472..5459c38952 100644
--- a/third_party/nix/src/nix/run.cc
+++ b/third_party/nix/src/nix/run.cc
@@ -225,7 +225,7 @@ void chrootHelper(int argc, char** argv) {
     createDirs(tmpDir + storeDir);
 
     if (mount(realStoreDir.c_str(), (tmpDir + storeDir).c_str(), "", MS_BIND,
-              0) == -1) {
+              nullptr) == -1) {
       throw SysError("mounting '%s' on '%s'", realStoreDir, storeDir);
     }
 
@@ -242,12 +242,13 @@ void chrootHelper(int argc, char** argv) {
       if (mkdir(dst.c_str(), 0700) == -1) {
         throw SysError("creating directory '%s'", dst);
       }
-      if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, 0) == -1) {
+      if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, nullptr) ==
+          -1) {
         throw SysError("mounting '%s' on '%s'", src, dst);
       }
     }
 
-    char* cwd = getcwd(0, 0);
+    char* cwd = getcwd(nullptr, 0);
     if (!cwd) {
       throw SysError("getting current directory");
     }
@@ -260,8 +261,8 @@ void chrootHelper(int argc, char** argv) {
     if (chdir(cwd) == -1) {
       throw SysError(format("chdir to '%s' in chroot") % cwd);
     }
-  } else if (mount(realStoreDir.c_str(), storeDir.c_str(), "", MS_BIND, 0) ==
-             -1) {
+  } else if (mount(realStoreDir.c_str(), storeDir.c_str(), "", MS_BIND,
+                   nullptr) == -1) {
     throw SysError("mounting '%s' on '%s'", realStoreDir, storeDir);
   }
 
diff --git a/third_party/nix/src/nix/search.cc b/third_party/nix/src/nix/search.cc
index 5978d197fe..78a1f21bc1 100644
--- a/third_party/nix/src/nix/search.cc
+++ b/third_party/nix/src/nix/search.cc
@@ -76,15 +76,14 @@ struct CmdSearch : SourceExprCommand, MixJSON {
     // Use "^" here instead of ".*" due to differences in resulting highlighting
     // (see #1893 -- libc++ claims empty search string is not in POSIX grammar)
     if (res.empty()) {
-      res.push_back("^");
+      res.emplace_back("^");
     }
 
     std::vector<std::regex> regexes;
     regexes.reserve(res.size());
 
     for (auto& re : res) {
-      regexes.push_back(
-          std::regex(re, std::regex::extended | std::regex::icase));
+      regexes.emplace_back(re, std::regex::extended | std::regex::icase);
     }
 
     auto state = getEvalState();
diff --git a/third_party/nix/src/nix/show-config.cc b/third_party/nix/src/nix/show-config.cc
index 85b3c330cd..51f02ed61b 100644
--- a/third_party/nix/src/nix/show-config.cc
+++ b/third_party/nix/src/nix/show-config.cc
@@ -7,7 +7,7 @@
 using namespace nix;
 
 struct CmdShowConfig : Command, MixJSON {
-  CmdShowConfig() {}
+  CmdShowConfig() = default;
 
   std::string name() override { return "show-config"; }