about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/globals.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T19·47+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T19·51+0100
commit39087321811e81e26a1a47d6967df1088dcf0e95 (patch)
tree57110be423eeb7869e9960466f4b17c0ea7cd961 /third_party/nix/src/libstore/globals.cc
parentcf40d08908ede4061eb15513b770c98877844b8b (diff)
style(3p/nix): Final act in the brace-wrapping saga r/777
This last change set was generated by a full clang-tidy run (including
compilation):

    clang-tidy -p ~/projects/nix-build/ \
      -checks=-*,readability-braces-around-statements -fix src/*/*.cc

Actually running clang-tidy requires some massaging to make it play
nice with Nix + meson, I'll be adding a wrapper or something for that soon.
Diffstat (limited to 'third_party/nix/src/libstore/globals.cc')
-rw-r--r--third_party/nix/src/libstore/globals.cc32
1 files changed, 19 insertions, 13 deletions
diff --git a/third_party/nix/src/libstore/globals.cc b/third_party/nix/src/libstore/globals.cc
index 19a0cde1ed2e..ade200f135ae 100644
--- a/third_party/nix/src/libstore/globals.cc
+++ b/third_party/nix/src/libstore/globals.cc
@@ -49,11 +49,12 @@ Settings::Settings()
   if (caFile == "") {
     for (auto& fn :
          {"/etc/ssl/certs/ca-certificates.crt",
-          "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"})
+          "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt"}) {
       if (pathExists(fn)) {
         caFile = fn;
         break;
       }
+    }
   }
 
   /* Backwards compatibility. */
@@ -112,26 +113,28 @@ const string nixVersion = PACKAGE_VERSION;
 
 template <>
 void BaseSetting<SandboxMode>::set(const std::string& str) {
-  if (str == "true")
+  if (str == "true") {
     value = smEnabled;
-  else if (str == "relaxed")
+  } else if (str == "relaxed") {
     value = smRelaxed;
-  else if (str == "false")
+  } else if (str == "false") {
     value = smDisabled;
-  else
+  } else {
     throw UsageError("option '%s' has invalid value '%s'", name, str);
+  }
 }
 
 template <>
 std::string BaseSetting<SandboxMode>::to_string() {
-  if (value == smEnabled)
+  if (value == smEnabled) {
     return "true";
-  else if (value == smRelaxed)
+  } else if (value == smRelaxed) {
     return "relaxed";
-  else if (value == smDisabled)
+  } else if (value == smDisabled) {
     return "false";
-  else
+  } else {
     abort();
+  }
 }
 
 template <>
@@ -160,11 +163,12 @@ void BaseSetting<SandboxMode>::convertToArg(Args& args,
 }
 
 void MaxBuildJobsSetting::set(const std::string& str) {
-  if (str == "auto")
+  if (str == "auto") {
     value = std::max(1U, std::thread::hardware_concurrency());
-  else if (!string2Int(str, value))
+  } else if (!string2Int(str, value)) {
     throw UsageError(
         "configuration setting '%s' should be 'auto' or an integer", name);
+  }
 }
 
 void initPlugins() {
@@ -172,8 +176,9 @@ void initPlugins() {
     Paths pluginFiles;
     try {
       auto ents = readDirectory(pluginFile);
-      for (const auto& ent : ents)
+      for (const auto& ent : ents) {
         pluginFiles.emplace_back(pluginFile + "/" + ent.name);
+      }
     } catch (SysError& e) {
       if (e.errNo != ENOTDIR) {
         throw;
@@ -184,9 +189,10 @@ void initPlugins() {
       /* handle is purposefully leaked as there may be state in the
          DSO needed by the action of the plugin. */
       void* handle = dlopen(file.c_str(), RTLD_LAZY | RTLD_LOCAL);
-      if (!handle)
+      if (!handle) {
         throw Error("could not dynamically open plugin file '%s': %s", file,
                     dlerror());
+      }
     }
   }