interceptor: consistently use curly braces for all statements

Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: I80b2773557ec561b944d63dd826fa5a08c0bb849
diff --git a/analysis.cc b/analysis.cc
index 05564c7..e230096 100644
--- a/analysis.cc
+++ b/analysis.cc
@@ -57,18 +57,22 @@
   while (true) {
     int ix;
     int c = getopt_long(argc, argv, "-l:t:o:", opts, &ix);
-    if (c == -1) break;
+    if (c == -1) {
+      break;
+    }
     switch (c) {
       case 'l':
         result.command_log = fs::absolute(optarg);
         break;
       case 't':
-        if (strcmp(optarg, "text") == 0)
+        if (strcmp(optarg, "text") == 0) {
           result.output_format = OutputFormat::TEXT;
-        if (strcmp(optarg, "compdb") == 0)
+        }
+        if (strcmp(optarg, "compdb") == 0) {
           result.output_format = OutputFormat::COMPDB;
-        else
+        } else {
           usage();
+        }
         break;
       case 'o':
         result.output = fs::absolute(optarg);
@@ -130,7 +134,9 @@
 
   for (const auto& command : log.commands()) {
     // skip anything that is not a compiler invocation
-    if (!COMPILERS.count(fs::path(command.args(0)).filename().native())) continue;
+    if (!COMPILERS.count(fs::path(command.args(0)).filename().native())) {
+      continue;
+    }
 
     // determine if we have a uniquely identifyable output
     const std::string single_output = [&]() {
@@ -145,21 +151,26 @@
     }();
 
     // skip preprocessor invocations
-    if (std::find(command.args().cbegin(), command.args().cend(), "-E") != command.args().cend())
+    if (std::find(command.args().cbegin(), command.args().cend(), "-E") != command.args().cend()) {
       continue;
+    }
 
     // now iterate over all inputs, emitting an entry for each source file
     for (const auto& input : command.inputs()) {
       // skip anything that does not look like a source file (object files,
       // force included headers, etc.)
-      if (!COMPILE_EXTENSIONS.count(fs::path(input).extension().native())) continue;
+      if (!COMPILE_EXTENSIONS.count(fs::path(input).extension().native())) {
+        continue;
+      }
 
       // ok, now we have a new command
       auto& compile_command = *compdb.add_commands();
 
       compile_command.set_directory(fs::path(log.root_dir()) / command.current_dir());
       compile_command.set_file(input);
-      if (!single_output.empty()) compile_command.set_output(single_output);
+      if (!single_output.empty()) {
+        compile_command.set_output(single_output);
+      }
       *compile_command.mutable_arguments() = {command.args().cbegin(), command.args().cend()};
     }
   }
diff --git a/interceptor.cc b/interceptor.cc
index fb7f3f3..1acb7b2 100644
--- a/interceptor.cc
+++ b/interceptor.cc
@@ -95,15 +95,21 @@
   std::string root_dir;
   if (auto it = command->env_vars().find(ENV_root_dir); it != command->env_vars().cend()) {
     root_dir = it->second;
-    if (root_dir[root_dir.size() - 1] != '/') root_dir += '/';
+    if (root_dir[root_dir.size() - 1] != '/') {
+      root_dir += '/';
+    }
   } else {
     return;
   }
 
   // determine the relative path to ROOT_DIR from the current working dir
   std::string rel_root = fs::relative(root_dir);
-  if (rel_root[rel_root.size() - 1] != '/') rel_root += '/';
-  if (rel_root == "./") rel_root.clear();
+  if (rel_root[rel_root.size() - 1] != '/') {
+    rel_root += '/';
+  }
+  if (rel_root == "./") {
+    rel_root.clear();
+  }
 
   // TODO: This is generally bad as this means we can't make anything relative.
   // This happens if the out dir is outside of the root.
@@ -155,8 +161,9 @@
 
   std::ostringstream cmd;
   cmd << command.program();
-  for (auto I = std::next(command.args().cbegin()), E = command.args().cend(); I != E; ++I)
+  for (auto I = std::next(command.args().cbegin()), E = command.args().cend(); I != E; ++I) {
     cmd << ' ' << escape(*I);
+  }
 
   os << cmd.str();
   return os;
@@ -242,7 +249,9 @@
 static AnalysisResult analyze_archiver(const std::string&, const ArgVec& args, const EnvMap&) {
   AnalysisResult result;
 
-  if (args.size() < 3) return result;
+  if (args.size() < 3) {
+    return result;
+  }
   // skip args[0] as this is the program itself
   // skip args[1] are the archiver flags
   // args[2] is the output
diff --git a/main.cc b/main.cc
index 49d33d2..36cb1bd 100644
--- a/main.cc
+++ b/main.cc
@@ -47,7 +47,9 @@
     auto c = getopt_long(argc, argv, "l:", long_options, &option_index);
 
     /* Detect the end of the options. */
-    if (c == -1) break;
+    if (c == -1) {
+      break;
+    }
 
     switch (c) {
       case 'l':
@@ -78,8 +80,9 @@
 static void setup_interceptor_library_path() {
   auto interceptor_library = fs::read_symlink("/proc/self/exe").parent_path().parent_path() /
                              "lib64" / "libinterceptor.so";
-  while (fs::is_symlink(interceptor_library))
+  while (fs::is_symlink(interceptor_library)) {
     interceptor_library = fs::read_symlink(interceptor_library);
+  }
   if (!fs::is_regular_file(interceptor_library)) {
     std::cerr << "Interceptor library could not be found!\n";
     exit(EX_CONFIG);
@@ -90,10 +93,11 @@
 static fs::path setup_root_dir() {
   const auto root_dir = getenv("ROOT_DIR");
   fs::path result;
-  if (root_dir != nullptr)
+  if (root_dir != nullptr) {
     result = root_dir;
-  else
+  } else {
     result = fs::current_path();
+  }
 
   setenv(ENV_root_dir, result.c_str(), 1);
 
@@ -130,9 +134,12 @@
         interceptor::Message message;
         while (true) {
           if (!google::protobuf::util::ParseDelimitedFromZeroCopyStream(&message, &input_stream,
-                                                                        nullptr))
+                                                                        nullptr)) {
             break;
-          if (message.has_command()) log.add_commands()->Swap(message.release_command());
+          }
+          if (message.has_command()) {
+            log.add_commands()->Swap(message.release_command());
+          }
         }
       }
       std::ofstream command_log(command_log_file_->c_str(), std::ios_base::binary);