about summary refs log tree commit diff
path: root/third_party/nix/src/nix-daemon
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/nix-daemon')
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon-proto.cc7
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon.cc56
2 files changed, 30 insertions, 33 deletions
diff --git a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
index 58f7754386e9..63c68ed1e5b1 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
@@ -22,6 +22,7 @@
 namespace nix::daemon {
 
 using ::grpc::Status;
+using ::nix::proto::BuildStatus;
 using ::nix::proto::PathInfo;
 using ::nix::proto::StorePath;
 using ::nix::proto::StorePaths;
@@ -84,7 +85,7 @@ struct RetrieveRegularNARSink : ParseSink {
 
 class WorkerServiceImpl final : public WorkerService::Service {
  public:
-  explicit WorkerServiceImpl(nix::Store& store) : store_(&store) {}
+  WorkerServiceImpl(nix::Store& store) : store_(&store) {}
 
   Status IsValidPath(grpc::ServerContext* context, const StorePath* request,
                      nix::proto::IsValidPathResponse* response) override {
@@ -394,8 +395,8 @@ class WorkerServiceImpl final : public WorkerService::Service {
     PathSet will_substitute;
     PathSet unknown;
     // TODO(grfn): Switch to concrete size type
-    unsigned long long download_size = 0;
-    unsigned long long nar_size = 0;
+    unsigned long long download_size;
+    unsigned long long nar_size;
 
     store_->queryMissing(targets, will_build, will_substitute, unknown,
                          download_size, nar_size);
diff --git a/third_party/nix/src/nix-daemon/nix-daemon.cc b/third_party/nix/src/nix-daemon/nix-daemon.cc
index fdb539d6628c..b36f9733c37a 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon.cc
@@ -183,7 +183,7 @@ struct RetrieveRegularNARSink : ParseSink {
   void createDirectory(const Path& path) override { regular = false; }
 
   void receiveContents(unsigned char* data, unsigned int len) override {
-    s.append(reinterpret_cast<const char*>(data), len);
+    s.append((const char*)data, len);
   }
 
   void createSymlink(const Path& path, const std::string& target) override {
@@ -296,8 +296,8 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
     }
 
     case wopAddToStore: {
-      bool fixed = 0;
-      bool recursive = 0;
+      bool fixed = false;
+      bool recursive = false;
       std::string hashType;
       std::string baseName;
       from >> baseName >> fixed /* obsolete */ >> recursive >> hashType;
@@ -376,7 +376,7 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
       auto drvs = readStorePaths<PathSet>(*store, from);
       BuildMode mode = bmNormal;
       if (GET_PROTOCOL_MINOR(clientVersion) >= 15) {
-        mode = static_cast<BuildMode>(readInt(from));
+        mode = (BuildMode)readInt(from);
 
         /* Repairing is not atomic, so disallowed for "untrusted"
            clients.  */
@@ -397,7 +397,7 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
       Path drvPath = readStorePath(*store, from);
       BasicDerivation drv;
       readDerivation(from, *store, drv);
-      auto buildMode = static_cast<BuildMode>(readInt(from));
+      auto buildMode = (BuildMode)readInt(from);
       logger->startWork();
       if (!trusted) {
         throw Error("you are not privileged to build derivations");
@@ -466,7 +466,7 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
 
     case wopCollectGarbage: {
       GCOptions options;
-      options.action = static_cast<GCOptions::GCAction>(readInt(from));
+      options.action = (GCOptions::GCAction)readInt(from);
       options.pathsToDelete = readStorePaths<PathSet>(*store, from);
       from >> options.ignoreLiveness >> options.maxFreed;
       // obsolete fields
@@ -639,15 +639,14 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
     }
 
     case wopVerifyStore: {
-      bool checkContents = 0;
-      bool repair = 0;
+      bool checkContents;
+      bool repair;
       from >> checkContents >> repair;
       logger->startWork();
       if (repair && !trusted) {
         throw Error("you are not privileged to repair paths");
       }
-      bool errors =
-          store->verifyStore(checkContents, static_cast<RepairFlag>(repair));
+      bool errors = store->verifyStore(checkContents, (RepairFlag)repair);
       logger->stopWork();
       to << static_cast<uint64_t>(errors);
       break;
@@ -675,8 +674,8 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
     }
 
     case wopAddToStoreNar: {
-      bool repair = 0;
-      bool dontCheckSigs = 0;
+      bool repair;
+      bool dontCheckSigs;
       ValidPathInfo info;
       info.path = readStorePath(*store, from);
       from >> info.deriver;
@@ -709,7 +708,7 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
       logger->startWork();
 
       // FIXME: race if addToStore doesn't read source?
-      store->addToStore(info, *source, static_cast<RepairFlag>(repair),
+      store->addToStore(info, *source, (RepairFlag)repair,
                         dontCheckSigs ? NoCheckSigs : CheckSigs, nullptr);
 
       logger->stopWork();
@@ -722,8 +721,8 @@ static void performOp(TunnelLogger* logger, const ref<Store>& store,
       PathSet willBuild;
       PathSet willSubstitute;
       PathSet unknown;
-      unsigned long long downloadSize = 0;
-      unsigned long long narSize = 0;
+      unsigned long long downloadSize;
+      unsigned long long narSize;
       store->queryMissing(targets, willBuild, willSubstitute, unknown,
                           downloadSize, narSize);
       logger->stopWork();
@@ -796,9 +795,9 @@ static void processConnection(bool trusted, const std::string& userName,
 
     /* Process client requests. */
     while (true) {
-      WorkerOp op{};
+      WorkerOp op;
       try {
-        op = static_cast<WorkerOp>(readInt(from));
+        op = (WorkerOp)readInt(from);
       } catch (Interrupted& e) {
         break;
       } catch (EndOfFile& e) {
@@ -848,8 +847,8 @@ static void sigChldHandler(int sigNo) {
 }
 
 static void setSigChldAction(bool autoReap) {
-  struct sigaction act {};
-  struct sigaction oact {};
+  struct sigaction act;
+  struct sigaction oact;
   act.sa_handler = autoReap ? sigChldHandler : SIG_DFL;
   sigfillset(&act.sa_mask);
   act.sa_flags = 0;
@@ -903,7 +902,7 @@ static PeerInfo getPeerInfo(int remote) {
 
 #if defined(SO_PEERCRED)
 
-  ucred cred{};
+  ucred cred;
   socklen_t credLen = sizeof(cred);
   if (getsockopt(remote, SOL_SOCKET, SO_PEERCRED, &cred, &credLen) == -1) {
     throw SysError("getting peer credentials");
@@ -969,7 +968,7 @@ static void daemonLoop(char** argv) {
     }
     Path socketPathRel = "./" + baseNameOf(socketPath);
 
-    struct sockaddr_un addr {};
+    struct sockaddr_un addr;
     addr.sun_family = AF_UNIX;
     strncpy(addr.sun_path, socketPathRel.c_str(), sizeof(addr.sun_path));
     if (addr.sun_path[sizeof(addr.sun_path) - 1] != '\0') {
@@ -982,8 +981,7 @@ static void daemonLoop(char** argv) {
        (everybody can connect --- provided they have access to the
        directory containing the socket). */
     mode_t oldMode = umask(0111);
-    int res = bind(fdSocket.get(), reinterpret_cast<struct sockaddr*>(&addr),
-                   sizeof(addr));
+    int res = bind(fdSocket.get(), (struct sockaddr*)&addr, sizeof(addr));
     umask(oldMode);
     if (res == -1) {
       throw SysError(format("cannot bind to socket '%1%'") % socketPath);
@@ -1004,12 +1002,11 @@ static void daemonLoop(char** argv) {
   while (true) {
     try {
       /* Accept a connection. */
-      struct sockaddr_un remoteAddr {};
+      struct sockaddr_un remoteAddr;
       socklen_t remoteAddrLen = sizeof(remoteAddr);
 
-      AutoCloseFD remote = accept(
-          fdSocket.get(), reinterpret_cast<struct sockaddr*>(&remoteAddr),
-          &remoteAddrLen);
+      AutoCloseFD remote =
+          accept(fdSocket.get(), (struct sockaddr*)&remoteAddr, &remoteAddrLen);
       checkInterrupt();
       if (!remote) {
         if (errno == EINTR) {
@@ -1094,7 +1091,7 @@ static int _main(int argc, char** argv) {
     auto stdio = false;
 
     parseCmdLine(argc, argv,
-                 [&](Strings::iterator& arg, const Strings::iterator& _end) {
+                 [&](Strings::iterator& arg, const Strings::iterator& end) {
                    if (*arg == "--daemon") {
                      ; /* ignored for backwards compatibility */
                    } else if (*arg == "--help") {
@@ -1132,8 +1129,7 @@ static int _main(int argc, char** argv) {
           throw Error(format("socket name %1% is too long") % socketName);
         }
 
-        if (connect(s, reinterpret_cast<struct sockaddr*>(&addr),
-                    sizeof(addr)) == -1) {
+        if (connect(s, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
           throw SysError(format("cannot connect to daemon at %1%") %
                          socketPath);
         }