about summary refs log tree commit diff
path: root/third_party/nix/src/libmain/shared.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-20T21·27+0100
committerVincent Ambo <tazjin@google.com>2020-05-20T21·27+0100
commit689ef502f5b0655c9923ed77da2ae3504630f473 (patch)
tree3e331c153646f136875f047cc3b9f0aad8c86341 /third_party/nix/src/libmain/shared.cc
parentd331d3a0b5c497a46e2636f308234be66566c04c (diff)
refactor(3p/nix): Apply clang-tidy's readability-* fixes r/788
This applies the readability fixes listed here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html
Diffstat (limited to 'third_party/nix/src/libmain/shared.cc')
-rw-r--r--third_party/nix/src/libmain/shared.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/third_party/nix/src/libmain/shared.cc b/third_party/nix/src/libmain/shared.cc
index 8ff7cebbee..5c20846911 100644
--- a/third_party/nix/src/libmain/shared.cc
+++ b/third_party/nix/src/libmain/shared.cc
@@ -37,8 +37,11 @@ void printGCWarning() {
 }
 
 void printMissing(ref<Store> store, const PathSet& paths) {
-  unsigned long long downloadSize, narSize;
-  PathSet willBuild, willSubstitute, unknown;
+  unsigned long long downloadSize;
+  unsigned long long narSize;
+  PathSet willBuild;
+  PathSet willSubstitute;
+  PathSet unknown;
   store->queryMissing(paths, willBuild, willSubstitute, unknown, downloadSize,
                       narSize);
   printMissing(store, willBuild, willSubstitute, unknown, downloadSize,
@@ -129,13 +132,13 @@ void initNix() {
   sigemptyset(&act.sa_mask);
   act.sa_handler = SIG_DFL;
   act.sa_flags = 0;
-  if (sigaction(SIGCHLD, &act, nullptr)) {
+  if (sigaction(SIGCHLD, &act, nullptr) != 0) {
     throw SysError("resetting SIGCHLD");
   }
 
   /* Install a dummy SIGUSR1 handler for use with pthread_kill(). */
   act.sa_handler = sigHandler;
-  if (sigaction(SIGUSR1, &act, nullptr)) {
+  if (sigaction(SIGUSR1, &act, nullptr) != 0) {
     throw SysError("handling SIGUSR1");
   }
 
@@ -319,7 +322,7 @@ int handleExceptions(const string& programName, std::function<void()> fun) {
     return 1;
   } catch (BaseError& e) {
     LOG(ERROR) << error << (settings.showTrace ? e.prefix() : "") << e.msg();
-    if (e.prefix() != "" && !settings.showTrace) {
+    if (!e.prefix().empty() && !settings.showTrace) {
       LOG(INFO) << "(use '--show-trace' to show detailed location information)";
     }
     return e.status;
@@ -335,11 +338,11 @@ int handleExceptions(const string& programName, std::function<void()> fun) {
 }
 
 RunPager::RunPager() {
-  if (!isatty(STDOUT_FILENO)) {
+  if (isatty(STDOUT_FILENO) == 0) {
     return;
   }
   char* pager = getenv("NIX_PAGER");
-  if (!pager) {
+  if (pager == nullptr) {
     pager = getenv("PAGER");
   }
   if (pager && ((string)pager == "" || (string)pager == "cat")) {
@@ -353,11 +356,11 @@ RunPager::RunPager() {
     if (dup2(toPager.readSide.get(), STDIN_FILENO) == -1) {
       throw SysError("dupping stdin");
     }
-    if (!getenv("LESS")) {
+    if (getenv("LESS") == nullptr) {
       setenv("LESS", "FRSXMK", 1);
     }
     restoreSignals();
-    if (pager) {
+    if (pager != nullptr) {
       execl("/bin/sh", "sh", "-c", pager, nullptr);
     }
     execlp("pager", "pager", nullptr);