diff options
Diffstat (limited to 'third_party/nix/src/libmain')
-rw-r--r-- | third_party/nix/src/libmain/shared.cc | 13 | ||||
-rw-r--r-- | third_party/nix/src/libmain/stack.cc | 10 |
2 files changed, 12 insertions, 11 deletions
diff --git a/third_party/nix/src/libmain/shared.cc b/third_party/nix/src/libmain/shared.cc index f63fe9c11c5a..8ff7cebbee4d 100644 --- a/third_party/nix/src/libmain/shared.cc +++ b/third_party/nix/src/libmain/shared.cc @@ -2,14 +2,15 @@ #include <algorithm> #include <cctype> +#include <csignal> #include <cstdlib> #include <exception> #include <iostream> #include <mutex> +#include <utility> #include <glog/logging.h> #include <openssl/crypto.h> -#include <signal.h> #include <sys/stat.h> #include <sys/time.h> #include <unistd.h> @@ -128,13 +129,13 @@ void initNix() { sigemptyset(&act.sa_mask); act.sa_handler = SIG_DFL; act.sa_flags = 0; - if (sigaction(SIGCHLD, &act, 0)) { + if (sigaction(SIGCHLD, &act, nullptr)) { throw SysError("resetting SIGCHLD"); } /* Install a dummy SIGUSR1 handler for use with pthread_kill(). */ act.sa_handler = sigHandler; - if (sigaction(SIGUSR1, &act, 0)) { + if (sigaction(SIGUSR1, &act, nullptr)) { throw SysError("handling SIGUSR1"); } @@ -159,7 +160,7 @@ void initNix() { /* Initialise the PRNG. */ struct timeval tv; - gettimeofday(&tv, 0); + gettimeofday(&tv, nullptr); srandom(tv.tv_usec); /* On macOS, don't use the per-session TMPDIR (as set e.g. by @@ -175,7 +176,7 @@ LegacyArgs::LegacyArgs( const std::string& programName, std::function<bool(Strings::iterator& arg, const Strings::iterator& end)> parseArg) - : MixCommonArgs(programName), parseArg(parseArg) { + : MixCommonArgs(programName), parseArg(std::move(parseArg)) { mkFlag() .longName("no-build-output") .shortName('Q') @@ -395,6 +396,6 @@ PrintFreed::~PrintFreed() { } } -Exit::~Exit() {} +Exit::~Exit() = default; } // namespace nix diff --git a/third_party/nix/src/libmain/stack.cc b/third_party/nix/src/libmain/stack.cc index 27c16f5d1f6b..87018b975c29 100644 --- a/third_party/nix/src/libmain/stack.cc +++ b/third_party/nix/src/libmain/stack.cc @@ -1,8 +1,8 @@ +#include <csignal> #include <cstddef> #include <cstdlib> #include <cstring> -#include <signal.h> #include <unistd.h> #include "types.hh" @@ -14,7 +14,7 @@ static void sigsegvHandler(int signo, siginfo_t* info, void* ctx) { the stack pointer. Unfortunately, getting the stack pointer is not portable. */ bool haveSP = true; - char* sp = 0; + char* sp = nullptr; #if defined(__x86_64__) && defined(REG_RSP) sp = (char*)((ucontext_t*)ctx)->uc_mcontext.gregs[REG_RSP]; #elif defined(REG_ESP) @@ -40,7 +40,7 @@ static void sigsegvHandler(int signo, siginfo_t* info, void* ctx) { sigfillset(&act.sa_mask); act.sa_handler = SIG_DFL; act.sa_flags = 0; - if (sigaction(SIGSEGV, &act, 0)) { + if (sigaction(SIGSEGV, &act, nullptr)) { abort(); } } @@ -58,7 +58,7 @@ void detectStackOverflow() { throw Error("cannot allocate alternative stack"); } stack.ss_flags = 0; - if (sigaltstack(&stack, 0) == -1) { + if (sigaltstack(&stack, nullptr) == -1) { throw SysError("cannot set alternative stack"); } @@ -66,7 +66,7 @@ void detectStackOverflow() { sigfillset(&act.sa_mask); act.sa_sigaction = sigsegvHandler; act.sa_flags = SA_SIGINFO | SA_ONSTACK; - if (sigaction(SIGSEGV, &act, 0)) { + if (sigaction(SIGSEGV, &act, nullptr)) { throw SysError("resetting SIGSEGV"); } #endif |