]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Low hanging fruits of some auto fixable improvements via clang-tidy (#545)
authorAlexander Lanin <alex@lanin.de>
Tue, 25 Feb 2020 20:14:01 +0000 (21:14 +0100)
committerGitHub <noreply@github.com>
Tue, 25 Feb 2020 20:14:01 +0000 (21:14 +0100)
27 files changed:
.clang-tidy
src/ArgsInfo.hpp
src/Config.cpp
src/FormatNonstdStringView.hpp
src/args.cpp
src/ccache.cpp
src/cleanup.cpp
src/compopt.cpp
src/counters.cpp
src/execute.cpp
src/exitfn.cpp
src/hash.cpp
src/hash.hpp
src/hashutil.cpp
src/language.cpp
src/legacy_util.cpp
src/lockfile.cpp
src/logging.cpp
src/manifest.cpp
src/stats.cpp
unittest/framework.hpp
unittest/main.cpp
unittest/test_ZstdCompression.cpp
unittest/test_args.cpp
unittest/test_argument_processing.cpp
unittest/test_compopt.cpp
unittest/test_legacy_util.cpp

index f6e7172e7043e589e5b42105349924175a58b0a3..89196e661df7a90cf0398b38483dcf25d0f724c8 100644 (file)
@@ -2,5 +2,7 @@
 Checks:          'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,-clang-analyzer-optin.performance.Padding'
 HeaderFilterRegex: 'src/.*|unittest/.*'
 CheckOptions:    
+  - key:             readability-braces-around-statements.ShortStatementLines
+    value:           1
 ...
 
index 33c6f7049efaabd88452980f9ef21c657b33731b..39aea7e390dbddbe96ed8144d09dddce6f1c367f 100644 (file)
@@ -95,7 +95,7 @@ struct ArgsInfo
   // Array for storing -arch options.
   static constexpr int max_arch_args = 10;
   size_t arch_args_size = 0;
-  char* arch_args[max_arch_args] = {NULL};
+  char* arch_args[max_arch_args] = {nullptr};
 
   // Relocating debuginfo in the format old=new.
   char** debug_prefix_maps = nullptr;
index 0dfb2d071c8791260ac963f977574bcd95124826..30a5f11df2cb22a70874f33c6400de40ef8f2e56 100644 (file)
@@ -654,6 +654,8 @@ void
 Config::visit_items(const ItemVisitor& item_visitor) const
 {
   std::vector<std::string> keys;
+  keys.reserve(k_config_key_table.size());
+
   for (const auto& item : k_config_key_table) {
     keys.emplace_back(item.first);
   }
index ded6de1d5fa04d9b7bc97c47f6de6baa3de77c06..0770a901218194f5605ee0bdb44da493e89e7042 100644 (file)
@@ -30,7 +30,7 @@ template<> struct formatter<nonstd::string_view>
 {
   template<typename ParseContext>
   constexpr auto
-  parse(ParseContext& ctx) -> decltype(ctx.begin())
+  parse(ParseContext& ctx) const -> decltype(ctx.begin())
   {
     return ctx.begin();
   }
index c2b5bf09fcd54748bd7ff006e87c423e52dfc91b..85fcfac95cbac34c991c789dc2ea2d24b58c21e2 100644 (file)
@@ -27,7 +27,7 @@ args_init(int init_argc, const char* const* init_args)
   struct args* args = (struct args*)x_malloc(sizeof(struct args));
   args->argc = 0;
   args->argv = (char**)x_malloc(sizeof(char*));
-  args->argv[0] = NULL;
+  args->argv[0] = nullptr;
   for (int i = 0; i < init_argc; i++) {
     args_add(args, init_args[i]);
   }
@@ -39,11 +39,11 @@ args_init_from_string(const char* command)
 {
   char* p = x_strdup(command);
   char* q = p;
-  char *word, *saveptr = NULL;
-  struct args* args = args_init(0, NULL);
+  char *word, *saveptr = nullptr;
+  struct args* args = args_init(0, nullptr);
   while ((word = strtok_r(q, " \t\r\n", &saveptr))) {
     args_add(args, word);
-    q = NULL;
+    q = nullptr;
   }
 
   free(p);
@@ -55,10 +55,10 @@ args_init_from_gcc_atfile(const char* filename)
 {
   char* argtext;
   if (!(argtext = read_text_file(filename, 0))) {
-    return NULL;
+    return nullptr;
   }
 
-  struct args* args = args_init(0, NULL);
+  struct args* args = args_init(0, nullptr);
   char* pos = argtext;
   char* argbuf = static_cast<char*>(x_malloc(strlen(argtext) + 1));
   char* argpos = argbuf;
@@ -210,7 +210,7 @@ args_add(struct args* args, const char* s)
   args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char*));
   args->argv[args->argc] = x_strdup(s);
   args->argc++;
-  args->argv[args->argc] = NULL;
+  args->argv[args->argc] = nullptr;
 }
 
 // Add all arguments in to_append to args.
@@ -229,7 +229,7 @@ args_pop(struct args* args, int n)
   while (n--) {
     args->argc--;
     free(args->argv[args->argc]);
-    args->argv[args->argc] = NULL;
+    args->argv[args->argc] = nullptr;
   }
 }
 
index 9f44a65577b555dc8d9e7fbf4ab0342cd507da0e..97c7c1e62fb2baa72f8b032e5bc9107e8b308988 100644 (file)
@@ -137,7 +137,7 @@ struct pending_tmp_file
 };
 
 // Temporary files to remove at program exit.
-static struct pending_tmp_file* pending_tmp_files = NULL;
+static struct pending_tmp_file* pending_tmp_files = nullptr;
 
 // How often (in seconds) to scan $CCACHE_DIR/tmp for left-over temporary
 // files.
@@ -165,11 +165,11 @@ add_prefix(const Context& ctx, struct args* args, const char* prefix_command)
     return;
   }
 
-  struct args* prefix = args_init(0, NULL);
+  struct args* prefix = args_init(0, nullptr);
   char* e = x_strdup(prefix_command);
-  char* saveptr = NULL;
+  char* saveptr = nullptr;
   for (char* tok = strtok_r(e, " ", &saveptr); tok;
-       tok = strtok_r(NULL, " ", &saveptr)) {
+       tok = strtok_r(nullptr, " ", &saveptr)) {
     char* p;
 
     p = find_executable(ctx, tok, MYNAME);
@@ -204,7 +204,7 @@ failed(enum stats stat, optional<int> exit_code)
 static const char*
 temp_dir(const Context& ctx)
 {
-  static const char* path = NULL;
+  static const char* path = nullptr;
   if (path) {
     return path; // Memoize
   }
@@ -216,20 +216,20 @@ temp_dir(const Context& ctx)
 }
 
 void
-block_signals(void)
+block_signals()
 {
 #ifndef _WIN32
-  sigprocmask(SIG_BLOCK, &fatal_signal_set, NULL);
+  sigprocmask(SIG_BLOCK, &fatal_signal_set, nullptr);
 #endif
 }
 
 void
-unblock_signals(void)
+unblock_signals()
 {
 #ifndef _WIN32
   sigset_t empty;
   sigemptyset(&empty);
-  sigprocmask(SIG_SETMASK, &empty, NULL);
+  sigprocmask(SIG_SETMASK, &empty, nullptr);
 #endif
 }
 
@@ -245,7 +245,7 @@ add_pending_tmp_file(const char* path)
 }
 
 static void
-do_clean_up_pending_tmp_files(void)
+do_clean_up_pending_tmp_files()
 {
   struct pending_tmp_file* p = pending_tmp_files;
   while (p) {
@@ -258,7 +258,7 @@ do_clean_up_pending_tmp_files(void)
 }
 
 static void
-clean_up_pending_tmp_files(void)
+clean_up_pending_tmp_files()
 {
   block_signals();
   do_clean_up_pending_tmp_files();
@@ -276,7 +276,7 @@ signal_handler(int signum)
   // If ccache was killed explicitly, then bring the compiler subprocess (if
   // any) with us as well.
   if (signum == SIGTERM && compiler_pid != 0
-      && waitpid(compiler_pid, NULL, WNOHANG) == 0) {
+      && waitpid(compiler_pid, nullptr, WNOHANG) == 0) {
     kill(compiler_pid, signum);
   }
 
@@ -284,7 +284,7 @@ signal_handler(int signum)
 
   if (compiler_pid != 0) {
     // Wait for compiler subprocess to exit before we snuff it.
-    waitpid(compiler_pid, NULL, 0);
+    waitpid(compiler_pid, nullptr, 0);
   }
 
   // Resend signal to ourselves to exit properly after returning from the
@@ -302,11 +302,11 @@ register_signal_handler(int signum)
 #  ifdef SA_RESTART
   act.sa_flags = SA_RESTART;
 #  endif
-  sigaction(signum, &act, NULL);
+  sigaction(signum, &act, nullptr);
 }
 
 static void
-set_up_signal_handlers(void)
+set_up_signal_handlers()
 {
   sigemptyset(&fatal_signal_set);
   sigaddset(&fatal_signal_set, SIGINT);
@@ -332,7 +332,7 @@ set_up_signal_handlers(void)
 static void
 clean_up_internal_tempdir(const Context& ctx)
 {
-  time_t now = time(NULL);
+  time_t now = time(nullptr);
   auto st = Stat::stat(ctx.config.cache_dir(), Stat::OnError::log);
   if (!st || st.mtime() + k_tempdir_cleanup_interval >= now) {
     // No cleanup needed.
@@ -549,7 +549,7 @@ do_remember_include_file(Context& ctx,
 
   if (ctx.config.direct_mode()) {
     if (!is_pch) { // else: the file has already been hashed.
-      char* source = NULL;
+      char* source = nullptr;
       size_t size;
       if (st.size() > 0) {
         if (!read_file(path.c_str(), st.size(), &source, &size)) {
@@ -688,14 +688,14 @@ process_preprocessed_file(Context& ctx,
   ctx.ignore_headers = nullptr;
   ctx.ignore_headers_len = 0;
   if (!ctx.config.ignore_headers_in_manifest().empty()) {
-    char *header, *p, *q, *saveptr = NULL;
+    char *header, *p, *q, *saveptr = nullptr;
     p = x_strdup(ctx.config.ignore_headers_in_manifest().c_str());
     q = p;
     while ((header = strtok_r(q, PATH_DELIM, &saveptr))) {
       ctx.ignore_headers = static_cast<char**>(x_realloc(
         ctx.ignore_headers, (ctx.ignore_headers_len + 1) * sizeof(char*)));
       ctx.ignore_headers[ctx.ignore_headers_len++] = x_strdup(header);
-      q = NULL;
+      q = nullptr;
     }
     free(p);
   }
@@ -817,7 +817,7 @@ process_preprocessed_file(Context& ctx,
         hash_string_buffer(hash, inc_path, strlen(inc_path));
       }
 
-      remember_include_file(ctx, inc_path, hash, system, NULL);
+      remember_include_file(ctx, inc_path, hash, system, nullptr);
       free(inc_path);
       p = q; // Everything of interest between p and q has been hashed now.
     } else if (q[0] == '.' && q[1] == 'i' && q[2] == 'n' && q[3] == 'c'
@@ -857,7 +857,7 @@ process_preprocessed_file(Context& ctx,
     std::string pch_path =
       make_relative_path(ctx, ctx.included_pch_file.c_str());
     hash_string(hash, pch_path);
-    remember_include_file(ctx, pch_path, hash, false, NULL);
+    remember_include_file(ctx, pch_path, hash, false, nullptr);
   }
 
   bool debug_included = getenv("CCACHE_DEBUG_INCLUDED");
@@ -916,7 +916,7 @@ use_relative_paths_in_depfile(const Context& ctx)
       if (relpath != token) {
         free(relpath);
       }
-      token = strtok_r(NULL, " \t", &saveptr);
+      token = strtok_r(nullptr, " \t", &saveptr);
     }
   }
 
@@ -968,7 +968,7 @@ result_name_from_depfile(Context& ctx, struct hash* hash)
     cc_log("Cannot open dependency file %s: %s",
            ctx.args_info.output_dep.c_str(),
            strerror(errno));
-    return NULL;
+    return nullptr;
   }
 
   char buf[10000];
@@ -976,7 +976,7 @@ result_name_from_depfile(Context& ctx, struct hash* hash)
     char* saveptr;
     char* token;
     for (token = strtok_r(buf, " \t\n", &saveptr); token;
-         token = strtok_r(NULL, " \t\n", &saveptr)) {
+         token = strtok_r(nullptr, " \t\n", &saveptr)) {
       if (str_endswith(token, ":") || str_eq(token, "\\")) {
         continue;
       }
@@ -996,7 +996,7 @@ result_name_from_depfile(Context& ctx, struct hash* hash)
     std::string pch_path =
       make_relative_path(ctx, ctx.included_pch_file.c_str());
     hash_string(hash, pch_path);
-    remember_include_file(ctx, pch_path, hash, false, NULL);
+    remember_include_file(ctx, pch_path, hash, false, nullptr);
   }
 
   bool debug_included = getenv("CCACHE_DEBUG_INCLUDED");
@@ -1094,11 +1094,7 @@ create_cachedir_tag(nonstd::string_view dir)
     return false;
   }
   f << cachedir_tag;
-  if (!f) {
-    return false;
-  }
-
-  return true;
+  return static_cast<bool>(f);
 }
 
 // Run the real compiler and put the result in cache.
@@ -1180,7 +1176,7 @@ to_cache(Context& ctx,
     }
     add_prefix(ctx, depend_mode_args, ctx.config.prefix_command().c_str());
 
-    ctx.time_of_compilation = time(NULL);
+    ctx.time_of_compilation = time(nullptr);
     status = execute(
       depend_mode_args->argv, tmp_stdout_fd, tmp_stderr_fd, &compiler_pid);
     args_free(depend_mode_args);
@@ -1367,9 +1363,9 @@ to_cache(Context& ctx,
 static struct digest*
 get_result_name_from_cpp(Context& ctx, struct args* args, struct hash* hash)
 {
-  ctx.time_of_compilation = time(NULL);
+  ctx.time_of_compilation = time(nullptr);
 
-  char* path_stderr = NULL;
+  char* path_stderr = nullptr;
   char* path_stdout = nullptr;
   int status;
   if (ctx.args_info.direct_i_file) {
@@ -1517,16 +1513,16 @@ hash_nvcc_host_compiler(const Context& ctx,
 #else
     const char* compilers[] = {"gcc", "g++"};
 #endif
-    for (size_t i = 0; i < ARRAY_SIZE(compilers); i++) {
+    for (const char* compiler : compilers) {
       if (ccbin) {
-        char* path = format("%s/%s", ccbin, compilers[i]);
+        char* path = format("%s/%s", ccbin, compiler);
         auto st = Stat::stat(path);
         if (st) {
           hash_compiler(ctx, hash, st, path, false);
         }
         free(path);
       } else {
-        char* path = find_executable(ctx, compilers[i], MYNAME);
+        char* path = find_executable(ctx, compiler, MYNAME);
         if (path) {
           auto st = Stat::stat(path, Stat::OnError::log);
           hash_compiler(ctx, hash, st, ccbin, false);
@@ -1580,7 +1576,8 @@ hash_common_info(const Context& ctx,
   if (!(ctx.config.sloppiness() & SLOPPY_LOCALE)) {
     // Hash environment variables that may affect localization of compiler
     // warning messages.
-    const char* envvars[] = {"LANG", "LC_ALL", "LC_CTYPE", "LC_MESSAGES", NULL};
+    const char* envvars[] = {
+      "LANG", "LC_ALL", "LC_CTYPE", "LC_MESSAGES", nullptr};
     for (const char** p = envvars; *p; ++p) {
       char* v = getenv(*p);
       if (v) {
@@ -1658,14 +1655,14 @@ hash_common_info(const Context& ctx,
     char* p = x_strdup(ctx.config.extra_files_to_hash().c_str());
     char* q = p;
     char* path;
-    char* saveptr = NULL;
+    char* saveptr = nullptr;
     while ((path = strtok_r(q, PATH_DELIM, &saveptr))) {
       cc_log("Hashing extra file %s", path);
       hash_delimiter(hash, "extrafile");
       if (!hash_file(hash, path)) {
         failed(STATS_BADEXTRAFILE);
       }
-      q = NULL;
+      q = nullptr;
     }
     free(p);
   }
@@ -1787,7 +1784,7 @@ calculate_result_name(Context& ctx,
       }
     }
 
-    char* p = NULL;
+    char* p = nullptr;
     if (str_startswith(args->argv[i], "-specs=")) {
       p = args->argv[i] + 7;
     } else if (str_startswith(args->argv[i], "--specs=")) {
@@ -1857,7 +1854,7 @@ calculate_result_name(Context& ctx,
   }
 
   if (!found_ccbin && ctx.args_info.actual_language == "cu") {
-    hash_nvcc_host_compiler(ctx, hash, NULL, NULL);
+    hash_nvcc_host_compiler(ctx, hash, nullptr, nullptr);
   }
 
   // For profile generation (-fprofile-arcs, -fprofile-generate):
@@ -1895,7 +1892,7 @@ calculate_result_name(Context& ctx,
     hash_string(hash, ctx.args_info.arch_args[i]);
   }
 
-  struct digest* result_name = NULL;
+  struct digest* result_name = nullptr;
   if (direct_mode) {
     // Hash environment variables that affect the preprocessor output.
     const char* envvars[] = {"CPATH",
@@ -1903,7 +1900,7 @@ calculate_result_name(Context& ctx,
                              "CPLUS_INCLUDE_PATH",
                              "OBJC_INCLUDE_PATH",
                              "OBJCPLUS_INCLUDE_PATH", // clang
-                             NULL};
+                             nullptr};
     for (const char** p = envvars; *p; ++p) {
       char* v = getenv(*p);
       if (v) {
@@ -1935,7 +1932,7 @@ calculate_result_name(Context& ctx,
     if (result & HASH_SOURCE_CODE_FOUND_TIME) {
       cc_log("Disabling direct mode");
       ctx.config.set_direct_mode(false);
-      return NULL;
+      return nullptr;
     }
 
     char manifest_name_string[DIGEST_STRING_BUFFER_SIZE];
@@ -1970,7 +1967,7 @@ calculate_result_name(Context& ctx,
                ctx.args_info.arch_args[i]);
         if (i != ctx.args_info.arch_args_size - 1) {
           free(result_name);
-          result_name = NULL;
+          result_name = nullptr;
         }
         args_pop(preprocessor_args, 1);
       }
@@ -2112,7 +2109,7 @@ is_precompiled_header(const char* path)
 }
 
 static bool
-color_output_possible(void)
+color_output_possible()
 {
   const char* term_env = getenv("TERM");
   return isatty(STDERR_FILENO) && term_env && strcasecmp(term_env, "DUMB") != 0;
@@ -2122,7 +2119,7 @@ static bool
 detect_pch(Context& ctx, const char* option, const char* arg, bool* found_pch)
 {
   // Try to be smart about detecting precompiled headers.
-  char* pch_file = NULL;
+  char* pch_file = nullptr;
   if (str_eq(option, "-include-pch") || str_eq(option, "-include-pth")) {
     if (Stat::stat(arg)) {
       cc_log("Detected use of precompiled header: %s", arg);
@@ -2215,23 +2212,24 @@ process_args(Context& ctx,
   // * those that only should be passed to the preprocessor (if run_second_cpp
   //   is false), and
   // * dependency options (like -MD and friends).
-  struct args* common_args = args_init(0, NULL);
+  struct args* common_args = args_init(0, nullptr);
   ArgsScopeGuard common_args_guard(common_args);
 
   // cpp_args contains arguments that were not added to common_args, i.e. those
   // that should only be passed to the preprocessor if run_second_cpp is false.
   // If run_second_cpp is true, they will be passed to the compiler as well.
-  struct args* cpp_args = args_init(0, NULL);
+  struct args* cpp_args = args_init(0, nullptr);
   ArgsScopeGuard cpp_args_guard(cpp_args);
 
   // dep_args contains dependency options like -MD. They are only passed to the
   // preprocessor, never to the compiler.
-  struct args* dep_args = args_init(0, NULL);
+  struct args* dep_args = args_init(0, nullptr);
   ArgsScopeGuard dep_args_guard(dep_args);
 
   // compiler_only_args contains arguments that should only be passed to the
   // compiler, not the preprocessor.
-  struct args* compiler_only_args = args_init(0, NULL); // will leak on failure
+  struct args* compiler_only_args =
+    args_init(0, nullptr); // will leak on failure
 
   bool found_color_diagnostics = false;
   bool found_directives_only = false;
@@ -3615,7 +3613,7 @@ do_cache_compilation(Context& ctx, char* argv[])
   // Need to dump log buffer as the last exit function to not lose any logs.
   exitfn_add_last(dump_debug_log_buffer_exitfn, &ctx);
 
-  FILE* debug_text_file = NULL;
+  FILE* debug_text_file = nullptr;
   if (ctx.config.debug()) {
     std::string path =
       fmt::format("{}.ccache-input-text", ctx.args_info.output_obj);
@@ -3652,8 +3650,8 @@ do_cache_compilation(Context& ctx, char* argv[])
   args_extend(args_to_hash, extra_args_to_hash);
 
   bool put_result_in_manifest = false;
-  struct digest* result_name = NULL;
-  struct digest* result_name_from_manifest = NULL;
+  struct digest* result_name = nullptr;
+  struct digest* result_name_from_manifest = nullptr;
   if (ctx.config.direct_mode()) {
     cc_log("Trying direct lookup");
     MTR_BEGIN("hash", "direct_hash");
@@ -3742,7 +3740,8 @@ do_cache_compilation(Context& ctx, char* argv[])
   add_prefix(ctx, compiler_args, ctx.config.prefix_command().c_str());
 
   // In depend_mode, extend the direct hash.
-  struct hash* depend_mode_hash = ctx.config.depend_mode() ? direct_hash : NULL;
+  struct hash* depend_mode_hash =
+    ctx.config.depend_mode() ? direct_hash : nullptr;
 
   // Run real compiler, sending output to cache.
   MTR_BEGIN("cache", "to_cache");
@@ -3764,30 +3763,30 @@ handle_main_options(int argc, char* argv[])
     PRINT_STATS,
   };
   static const struct option options[] = {
-    {"cleanup", no_argument, 0, 'c'},
-    {"clear", no_argument, 0, 'C'},
-    {"dump-manifest", required_argument, 0, DUMP_MANIFEST},
-    {"dump-result", required_argument, 0, DUMP_RESULT},
-    {"get-config", required_argument, 0, 'k'},
-    {"hash-file", required_argument, 0, HASH_FILE},
-    {"help", no_argument, 0, 'h'},
-    {"max-files", required_argument, 0, 'F'},
-    {"max-size", required_argument, 0, 'M'},
-    {"print-stats", no_argument, 0, PRINT_STATS},
-    {"recompress", required_argument, 0, 'X'},
-    {"set-config", required_argument, 0, 'o'},
-    {"show-compression", no_argument, 0, 'x'},
-    {"show-config", no_argument, 0, 'p'},
-    {"show-stats", no_argument, 0, 's'},
-    {"version", no_argument, 0, 'V'},
-    {"zero-stats", no_argument, 0, 'z'},
-    {0, 0, 0, 0}};
+    {"cleanup", no_argument, nullptr, 'c'},
+    {"clear", no_argument, nullptr, 'C'},
+    {"dump-manifest", required_argument, nullptr, DUMP_MANIFEST},
+    {"dump-result", required_argument, nullptr, DUMP_RESULT},
+    {"get-config", required_argument, nullptr, 'k'},
+    {"hash-file", required_argument, nullptr, HASH_FILE},
+    {"help", no_argument, nullptr, 'h'},
+    {"max-files", required_argument, nullptr, 'F'},
+    {"max-size", required_argument, nullptr, 'M'},
+    {"print-stats", no_argument, nullptr, PRINT_STATS},
+    {"recompress", required_argument, nullptr, 'X'},
+    {"set-config", required_argument, nullptr, 'o'},
+    {"show-compression", no_argument, nullptr, 'x'},
+    {"show-config", no_argument, nullptr, 'p'},
+    {"show-stats", no_argument, nullptr, 's'},
+    {"version", no_argument, nullptr, 'V'},
+    {"zero-stats", no_argument, nullptr, 'z'},
+    {nullptr, 0, nullptr, 0}};
 
   Context& ctx = initialize(argc, argv);
   (void)ctx;
 
   int c;
-  while ((c = getopt_long(argc, argv, "cCk:hF:M:po:sVxX:z", options, NULL))
+  while ((c = getopt_long(argc, argv, "cCk:hF:M:po:sVxX:z", options, nullptr))
          != -1) {
     switch (c) {
     case DUMP_MANIFEST:
@@ -3845,7 +3844,7 @@ handle_main_options(int argc, char* argv[])
       break;
 
     case 'F': { // --max-files
-      ctx.config.set_value_in_file(
+      Config::set_value_in_file(
         ctx.config.primary_config_path(), "max_files", optarg);
       unsigned files = atoi(optarg);
       if (files == 0) {
@@ -3861,7 +3860,7 @@ handle_main_options(int argc, char* argv[])
       if (!parse_size_with_suffix(optarg, &size)) {
         fatal("invalid size: %s", optarg);
       }
-      ctx.config.set_value_in_file(
+      Config::set_value_in_file(
         ctx.config.primary_config_path(), "max_size", optarg);
       if (size == 0) {
         printf("Unset cache size limit\n");
@@ -3880,8 +3879,7 @@ handle_main_options(int argc, char* argv[])
       }
       char* key = x_strndup(optarg, p - optarg);
       char* value = p + 1;
-      ctx.config.set_value_in_file(
-        ctx.config.primary_config_path(), key, value);
+      Config::set_value_in_file(ctx.config.primary_config_path(), key, value);
       free(key);
       break;
     }
index 65589b6defdd30bc8a3387385d48d87bd479bf2c..0001db28be11a84268880ede03cc5a215e635eac 100644 (file)
@@ -61,7 +61,7 @@ clean_up_dir(const std::string& subdir,
 
   uint64_t cache_size = 0;
   uint32_t files_in_cache = 0;
-  time_t current_time = time(NULL);
+  time_t current_time = time(nullptr);
 
   for (size_t i = 0; i < files.size();
        ++i, progress_receiver(1.0 / 3 + 1.0 * i / files.size() / 3)) {
index 885cfa0236a03802f821c3774ab1b04c99484c44..3d70b89e2d7d9f7f8a39f6c37e65582bb1303e9f 100644 (file)
@@ -183,11 +183,11 @@ compopt_short(bool (*fn)(const char*), const char* option)
 }
 
 // Used by unittest/test_compopt.c.
-bool compopt_verify_sortedness_and_flags(void);
+bool compopt_verify_sortedness_and_flags();
 
 // For test purposes.
 bool
-compopt_verify_sortedness_and_flags(void)
+compopt_verify_sortedness_and_flags()
 {
   for (size_t i = 0; i < ARRAY_SIZE(compopts); i++) {
     if (compopts[i].type & TOO_HARD && compopts[i].type & TAKES_CONCAT_ARG) {
index 2de240814871d942843840ef549b489ddf1f4da3..6eda43a44bb1e1356845134a9a36dbf54278c6fb 100644 (file)
@@ -28,7 +28,7 @@ struct counters*
 counters_init(size_t initial_size)
 {
   auto c = static_cast<counters*>(x_malloc(sizeof(counters)));
-  c->data = NULL;
+  c->data = nullptr;
   c->size = 0;
   c->allocated = 0;
   counters_resize(c, initial_size);
index b47741950fe5682cb93d41db2f8c0a1cced5ab56..67e1d9504ebc52b161b46ab224775ef36a5bd0b5 100644 (file)
@@ -314,7 +314,7 @@ find_executable(const Context& ctx, const char* name, const char* exclude_name)
   }
   if (!path) {
     cc_log("No PATH variable");
-    return NULL;
+    return nullptr;
   }
 
   return find_executable_in_path(name, exclude_name, path);
@@ -333,9 +333,9 @@ find_executable_in_path(const char* name,
 
   // Search the path looking for the first compiler of the right name that
   // isn't us.
-  char* saveptr = NULL;
+  char* saveptr = nullptr;
   for (char* tok = strtok_r(path_buf, PATH_DELIM, &saveptr); tok;
-       tok = strtok_r(NULL, PATH_DELIM, &saveptr)) {
+       tok = strtok_r(nullptr, PATH_DELIM, &saveptr)) {
 #ifdef _WIN32
     char namebuf[MAX_PATH];
     int ret = SearchPath(tok, name, NULL, sizeof(namebuf), namebuf, NULL);
@@ -373,7 +373,7 @@ find_executable_in_path(const char* name,
   }
 
   free(path_buf);
-  return NULL;
+  return nullptr;
 }
 
 void
index 612a84ac033e7278a9783ba4e34651c4229d0d88..5b1b153c6206d5a5bc6a279a2ae1eb34b2f4f03e 100644 (file)
@@ -31,7 +31,7 @@ struct exit_function
 
 struct nullary_exit_function
 {
-  void (*function)(void);
+  void (*function)();
 };
 
 static struct exit_function* exit_functions;
@@ -47,7 +47,7 @@ call_nullary_exit_function(void* context)
 
 // Initialize exit functions. Must be called once before exitfn_add* are used.
 void
-exitfn_init(void)
+exitfn_init()
 {
   if (atexit(exitfn_call) != 0) {
     fatal("atexit failed: %s", strerror(errno));
@@ -57,7 +57,7 @@ exitfn_init(void)
 // Add a nullary function to be called when ccache exits. Functions are called
 // in reverse order.
 void
-exitfn_add_nullary(void (*function)(void))
+exitfn_add_nullary(void (*function)())
 {
   auto p = static_cast<exit_function*>(x_malloc(sizeof(exit_function)));
   p->function = reinterpret_cast<void (*)(void*)>(function);
@@ -85,7 +85,7 @@ exitfn_add_last(void (*function)(void*), void* context)
   auto p = static_cast<exit_function*>(x_malloc(sizeof(exit_function)));
   p->function = function;
   p->context = context;
-  p->next = NULL;
+  p->next = nullptr;
 
   struct exit_function** q = &exit_functions;
   while (*q) {
@@ -105,17 +105,16 @@ exitfn_delete_context(Context* ctx)
 
 // Call added functions.
 void
-exitfn_call(void)
+exitfn_call()
 {
   struct exit_function* p = exit_functions;
-  exit_functions = NULL;
+  exit_functions = nullptr;
   while (p) {
     p->function(p->context);
     struct exit_function* q = p;
     p = p->next;
     free(q);
   }
-  if (context_to_clean_up) {
-    delete context_to_clean_up;
-  }
+
+  delete context_to_clean_up;
 }
index da0a813b5ecf3d249906f1e8baafacb87244eea3..edde65aebb851294847a0c081589abc78e83154f 100644 (file)
@@ -65,12 +65,12 @@ do_debug_text(struct hash* hash, const void* s, size_t len)
 }
 
 struct hash*
-hash_init(void)
+hash_init()
 {
   auto hash = static_cast<struct hash*>(malloc(sizeof(struct hash)));
   blake2b_init(&hash->state, DIGEST_SIZE);
-  hash->debug_binary = NULL;
-  hash->debug_text = NULL;
+  hash->debug_binary = nullptr;
+  hash->debug_text = nullptr;
   return hash;
 }
 
@@ -79,8 +79,8 @@ hash_copy(struct hash* hash)
 {
   auto result = static_cast<struct hash*>(malloc(sizeof(struct hash)));
   result->state = hash->state;
-  result->debug_binary = NULL;
-  result->debug_text = NULL;
+  result->debug_binary = nullptr;
+  result->debug_text = nullptr;
   return result;
 }
 
index cfc092a09d7b50b88ecea44c6f8f3ab0d3edc765..9b88a413040501d16d9e0200e2bc1f512cf61933 100644 (file)
@@ -43,7 +43,7 @@ bool digests_equal(const struct digest* d1, const struct digest* d2);
 struct hash;
 
 // Create a new hash state.
-struct hash* hash_init(void);
+struct hash* hash_init();
 
 // Create a new hash state from an existing hash state.
 struct hash* hash_copy(struct hash* hash);
index 58ebcb9c54726160c93b028cd69a4511003c022b..f8ac485350b06a4686ca7c2808fcc46d4a3cf0f3 100644 (file)
@@ -210,7 +210,7 @@ hash_source_code_string(const Config& config,
 
     // Make sure that the hash sum changes if the (potential) expansion of
     // __DATE__ changes.
-    time_t t = time(NULL);
+    time_t t = time(nullptr);
     struct tm now;
     hash_delimiter(hash, "date");
     if (!localtime_r(&t, &now)) {
@@ -430,13 +430,13 @@ hash_multicommand_output(struct hash* hash,
   char* command_string = x_strdup(commands);
   char* p = command_string;
   char* command;
-  char* saveptr = NULL;
+  char* saveptr = nullptr;
   bool ok = true;
   while ((command = strtok_r(p, ";", &saveptr))) {
     if (!hash_command_output(hash, command, compiler)) {
       ok = false;
     }
-    p = NULL;
+    p = nullptr;
   }
   free(command_string);
   return ok;
index df8b9d4eb6680254285a53eb854f40caaae3f371..315312d5198e9c832808b55643f411e601021279 100644 (file)
@@ -66,7 +66,7 @@ static const struct
   {".tcc", "c++-header"},
   {".TCC", "c++-header"},
   {".cu", "cu"},
-  {NULL, NULL},
+  {nullptr, nullptr},
 };
 
 // Supported languages and corresponding preprocessed languages.
@@ -92,7 +92,7 @@ static const struct
   {"objective-c++-cpp-output", "objective-c++-cpp-output"},
   {"assembler-with-cpp", "assembler"},
   {"assembler", "assembler"},
-  {NULL, NULL},
+  {nullptr, nullptr},
 };
 
 // Guess the language of a file based on its extension. Returns NULL if the
@@ -106,7 +106,7 @@ language_for_file(const char* fname)
       return extensions[i].language;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 // Return the preprocessed language for a given language, or NULL if unknown.
@@ -114,14 +114,14 @@ const char*
 p_language_for_language(const char* language)
 {
   if (!language) {
-    return NULL;
+    return nullptr;
   }
   for (int i = 0; languages[i].language; ++i) {
     if (str_eq(language, languages[i].language)) {
       return languages[i].p_language;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 // Return the default file extension (including dot) for a language, or NULL if
@@ -130,20 +130,20 @@ const char*
 extension_for_language(const char* language)
 {
   if (!language) {
-    return NULL;
+    return nullptr;
   }
   for (int i = 0; extensions[i].extension; i++) {
     if (str_eq(language, extensions[i].language)) {
       return extensions[i].extension;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 bool
 language_is_supported(const char* language)
 {
-  return p_language_for_language(language) != NULL;
+  return p_language_for_language(language) != nullptr;
 }
 
 bool
index ef46e5415fdfa23e5f1dceba99c860c0ed9de537..e43043645defa6818464700461a266581fc9a5a8 100644 (file)
@@ -109,7 +109,7 @@ mkstemp(char* name_template)
 
 #ifndef _WIN32
 static mode_t
-get_umask(void)
+get_umask()
 {
   static bool mask_retrieved = false;
   static mode_t mask;
@@ -138,7 +138,7 @@ clone_file(const char* src, const char* dest, bool via_tmp_file)
   }
 
   int dest_fd;
-  char* tmp_file = NULL;
+  char* tmp_file = nullptr;
   if (via_tmp_file) {
     tmp_file = x_strdup(dest);
     dest_fd = create_tmp_fd(&tmp_file);
@@ -202,7 +202,7 @@ copy_file(const char* src, const char* dest, bool via_tmp_file)
   }
 
   int dest_fd;
-  char* tmp_file = NULL;
+  char* tmp_file = nullptr;
   if (via_tmp_file) {
     tmp_file = x_strdup(dest);
     dest_fd = create_tmp_fd(&tmp_file);
@@ -246,7 +246,7 @@ move_file(const char* src, const char* dest)
 
 // Return a static string with the current hostname.
 const char*
-get_hostname(void)
+get_hostname()
 {
   static char hostname[260] = "";
 
@@ -320,7 +320,7 @@ get_hostname(void)
 // Return a string to be passed to mkstemp to create a temporary file. Also
 // tries to cope with NFS by adding the local hostname.
 const char*
-tmp_string(void)
+tmp_string()
 {
   static char* ret;
   if (!ret) {
@@ -336,7 +336,7 @@ format(const char* format, ...)
   va_list ap;
   va_start(ap, format);
 
-  char* ptr = NULL;
+  char* ptr = nullptr;
   if (vasprintf(&ptr, format, ap) == -1) {
     fatal("Out of memory in format");
   }
@@ -403,7 +403,7 @@ x_malloc(size_t size)
   if (size == 0) {
     // malloc() may return NULL if size is zero, so always do this to make sure
     // that the code handles it regardless of platform.
-    return NULL;
+    return nullptr;
   }
   void* ret = malloc(size);
   if (!ret) {
@@ -454,7 +454,7 @@ void
 reformat(char** ptr, const char* format, ...)
 {
   char* saved = *ptr;
-  *ptr = NULL;
+  *ptr = nullptr;
 
   va_list ap;
   va_start(ap, format);
@@ -668,7 +668,7 @@ create_tmp_file(char** fname, const char* mode)
 
 // Return current user's home directory, or NULL if it can't be determined.
 const char*
-get_home_directory(void)
+get_home_directory()
 {
   const char* p = getenv("HOME");
   if (p) {
@@ -688,7 +688,7 @@ get_home_directory(void)
     }
   }
 #endif
-  return NULL;
+  return nullptr;
 }
 
 // Check whether s1 and s2 have the same executable name.
@@ -729,7 +729,7 @@ void
 update_mtime(const char* path)
 {
 #ifdef HAVE_UTIMES
-  utimes(path, NULL);
+  utimes(path, nullptr);
 #else
   utime(path, NULL);
 #endif
@@ -893,7 +893,7 @@ read_file(const char* path, size_t size_hint, char** data, size_t* size)
   if (ret == -1) {
     cc_log("Failed reading %s", path);
     free(*data);
-    *data = NULL;
+    *data = nullptr;
     return false;
   }
 
@@ -913,7 +913,7 @@ read_text_file(const char* path, size_t size_hint)
     data[size] = '\0';
     return data;
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -972,7 +972,7 @@ char*
 subst_env_in_string(const char* str, char** errmsg)
 {
   assert(errmsg);
-  *errmsg = NULL;
+  *errmsg = nullptr;
 
   char* result = x_strdup("");
   const char* p = str; // Interval start.
@@ -982,7 +982,7 @@ subst_env_in_string(const char* str, char** errmsg)
       reformat(&result, "%s%.*s", result, (int)(q - p), p);
       if (!expand_variable(&q, &result, errmsg)) {
         free(result);
-        return NULL;
+        return nullptr;
       }
       p = q + 1;
     }
@@ -1005,11 +1005,11 @@ set_cloexec_flag(int fd)
 }
 
 double
-time_seconds(void)
+time_seconds()
 {
 #ifdef HAVE_GETTIMEOFDAY
   struct timeval tv;
-  gettimeofday(&tv, NULL);
+  gettimeofday(&tv, nullptr);
   return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
 #else
   return (double)time(NULL);
index 6092e6ad4c235cb1a4448c470abe8184b5eb26f0..a58a4907b136a369d209a186f92e38177d5586f8 100644 (file)
@@ -33,9 +33,9 @@ bool
 lockfile_acquire(const char* path, unsigned staleness_limit)
 {
   char* lockfile = format("%s.lock", path);
-  char* my_content = NULL;
-  char* content = NULL;
-  char* initial_content = NULL;
+  char* my_content = nullptr;
+  char* content = nullptr;
+  char* initial_content = nullptr;
   const char* hostname = get_hostname();
   bool acquired = false;
   unsigned to_sleep = 1000; // Microseconds.
@@ -43,7 +43,8 @@ lockfile_acquire(const char* path, unsigned staleness_limit)
 
   while (true) {
     free(my_content);
-    my_content = format("%s:%d:%d", hostname, (int)getpid(), (int)time(NULL));
+    my_content =
+      format("%s:%d:%d", hostname, (int)getpid(), (int)time(nullptr));
 
 #if defined(_WIN32) || defined(__CYGWIN__)
     int fd = open(lockfile, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0666);
index f59877ad5f2b5e2aeb15e742934a1dcce555fad8..3ef5c785b5019cc5beb7e090cb71307df2de4438 100644 (file)
@@ -120,7 +120,7 @@ log_prefix(bool log_updated_time)
     char timestamp[100];
     struct tm tm;
     struct timeval tv;
-    gettimeofday(&tv, NULL);
+    gettimeofday(&tv, nullptr);
 #  ifdef __MINGW64_VERSION_MAJOR
     localtime_r((time_t*)&tv.tv_sec, &tm);
 #  else
@@ -150,11 +150,11 @@ log_prefix(bool log_updated_time)
   }
 }
 
-static void warn_log_fail(void) ATTR_NORETURN;
+static void warn_log_fail() ATTR_NORETURN;
 
 // Warn about failure writing to the log file and then exit.
 static void
-warn_log_fail(void)
+warn_log_fail()
 {
   // Note: Can't call fatal() since that would lead to recursion.
   fprintf(stderr,
index 764a948719f5c31da82c020d431592144277cbea..961c62681eac23f1b6f55a37281f9729216cd772 100644 (file)
@@ -191,6 +191,8 @@ struct ManifestData
     }
 
     std::vector<uint32_t> file_info_indexes;
+    file_info_indexes.reserve(included_files.size());
+
     for (const auto& item : included_files) {
       file_info_indexes.push_back(get_file_info_index(item.first,
                                                       item.second,
@@ -337,15 +339,15 @@ write_manifest(const Config& config,
 {
   uint64_t payload_size = 0;
   payload_size += 4; // n_files
-  for (size_t i = 0; i < mf.files.size(); ++i) {
-    payload_size += 2 + mf.files[i].length();
+  for (const auto& file : mf.files) {
+    payload_size += 2 + file.length();
   }
   payload_size += 4; // n_file_infos
   payload_size += mf.file_infos.size() * (4 + DIGEST_SIZE + 8 + 8 + 8);
   payload_size += 4; // n_results
-  for (size_t i = 0; i < mf.results.size(); ++i) {
+  for (const auto& result : mf.results) {
     payload_size += 4; // n_file_info_indexes
-    payload_size += mf.results[i].file_info_indexes.size() * 4;
+    payload_size += result.file_info_indexes.size() * 4;
     payload_size += DIGEST_SIZE;
   }
 
@@ -357,27 +359,27 @@ write_manifest(const Config& config,
                           Compression::level_from_config(config),
                           payload_size);
   writer.write<uint32_t>(mf.files.size());
-  for (uint32_t i = 0; i < mf.files.size(); ++i) {
-    writer.write<uint16_t>(mf.files[i].length());
-    writer.write(mf.files[i].data(), mf.files[i].length());
+  for (const auto& file : mf.files) {
+    writer.write<uint16_t>(file.length());
+    writer.write(file.data(), file.length());
   }
 
   writer.write<uint32_t>(mf.file_infos.size());
-  for (uint32_t i = 0; i < mf.file_infos.size(); ++i) {
-    writer.write<uint32_t>(mf.file_infos[i].index);
-    writer.write(mf.file_infos[i].digest.bytes, DIGEST_SIZE);
-    writer.write(mf.file_infos[i].fsize);
-    writer.write(mf.file_infos[i].mtime);
-    writer.write(mf.file_infos[i].ctime);
+  for (const auto& file_info : mf.file_infos) {
+    writer.write<uint32_t>(file_info.index);
+    writer.write(file_info.digest.bytes, DIGEST_SIZE);
+    writer.write(file_info.fsize);
+    writer.write(file_info.mtime);
+    writer.write(file_info.ctime);
   }
 
   writer.write<uint32_t>(mf.results.size());
-  for (uint32_t i = 0; i < mf.results.size(); ++i) {
-    writer.write<uint32_t>(mf.results[i].file_info_indexes.size());
-    for (uint32_t j = 0; j < mf.results[i].file_info_indexes.size(); ++j) {
-      writer.write(mf.results[i].file_info_indexes[j]);
+  for (const auto& result : mf.results) {
+    writer.write<uint32_t>(result.file_info_indexes.size());
+    for (uint32_t j = 0; j < result.file_info_indexes.size(); ++j) {
+      writer.write(result.file_info_indexes[j]);
     }
-    writer.write(mf.results[i].name.bytes, DIGEST_SIZE);
+    writer.write(result.name.bytes, DIGEST_SIZE);
   }
 
   writer.finalize();
@@ -392,8 +394,8 @@ verify_result(const Context& ctx,
               std::unordered_map<std::string, FileStats>& stated_files,
               std::unordered_map<std::string, digest>& hashed_files)
 {
-  for (uint32_t i = 0; i < result.file_info_indexes.size(); ++i) {
-    const auto& fi = mf.file_infos[result.file_info_indexes[i]];
+  for (uint32_t file_info_index : result.file_info_indexes) {
+    const auto& fi = mf.file_infos[file_info_index];
     const auto& path = mf.files[fi.index];
 
     auto stated_files_iter = stated_files.find(path);
@@ -494,7 +496,7 @@ manifest_get(const Context& ctx, const std::string& path)
   std::unordered_map<std::string, digest> hashed_files;
 
   // Check newest result first since it's a bit more likely to match.
-  struct digest* name = NULL;
+  struct digest* name = nullptr;
   for (uint32_t i = mf->results.size(); i > 0; i--) {
     if (verify_result(
           ctx, *mf, mf->results[i - 1], stated_files, hashed_files)) {
@@ -606,8 +608,8 @@ manifest_dump(const std::string& path, FILE* stream)
     char name[DIGEST_STRING_BUFFER_SIZE];
     fmt::print(stream, "  {}:\n", i);
     fmt::print(stream, "    File info indexes:");
-    for (unsigned j = 0; j < mf->results[i].file_info_indexes.size(); ++j) {
-      fmt::print(stream, " {}", mf->results[i].file_info_indexes[j]);
+    for (uint32_t file_info_index : mf->results[i].file_info_indexes) {
+      fmt::print(stream, " {}", file_info_index);
     }
     fmt::print(stream, "\n");
     digest_as_string(&mf->results[i].name, name);
index ebfccbedac3b7716dfb569363052c9215511cbf2..992bd6f412474df4dc134217db5af50a3c3e32b7 100644 (file)
@@ -75,90 +75,102 @@ static struct
   {STATS_CACHEHIT_DIR,
    "direct_cache_hit",
    "cache hit (direct)",
-   NULL,
+   nullptr,
    FLAG_ALWAYS},
   {STATS_CACHEHIT_CPP,
    "preprocessed_cache_hit",
    "cache hit (preprocessed)",
-   NULL,
+   nullptr,
    FLAG_ALWAYS},
-  {STATS_CACHEMISS, "cache_miss", "cache miss", NULL, FLAG_ALWAYS},
-  {STATS_LINK, "called_for_link", "called for link", NULL, 0},
+  {STATS_CACHEMISS, "cache_miss", "cache miss", nullptr, FLAG_ALWAYS},
+  {STATS_LINK, "called_for_link", "called for link", nullptr, 0},
   {STATS_PREPROCESSING,
    "called_for_preprocessing",
    "called for preprocessing",
-   NULL,
+   nullptr,
+   0},
+  {STATS_MULTIPLE,
+   "multiple_source_files",
+   "multiple source files",
+   nullptr,
    0},
-  {STATS_MULTIPLE, "multiple_source_files", "multiple source files", NULL, 0},
   {STATS_STDOUT,
    "compiler_produced_stdout",
    "compiler produced stdout",
-   NULL,
+   nullptr,
    0},
   {STATS_NOOUTPUT,
    "compiler_produced_no_output",
    "compiler produced no output",
-   NULL,
+   nullptr,
    0},
   {STATS_EMPTYOUTPUT,
    "compiler_produced_empty_output",
    "compiler produced empty output",
-   NULL,
+   nullptr,
    0},
-  {STATS_STATUS, "compile_failed", "compile failed", NULL, 0},
-  {STATS_ERROR, "internal_error", "ccache internal error", NULL, 0},
-  {STATS_PREPROCESSOR, "preprocessor_error", "preprocessor error", NULL, 0},
+  {STATS_STATUS, "compile_failed", "compile failed", nullptr, 0},
+  {STATS_ERROR, "internal_error", "ccache internal error", nullptr, 0},
+  {STATS_PREPROCESSOR, "preprocessor_error", "preprocessor error", nullptr, 0},
   {STATS_CANTUSEPCH,
    "could_not_use_precompiled_header",
    "can't use precompiled header",
-   NULL,
+   nullptr,
+   0},
+  {STATS_CANTUSEMODULES,
+   "could_not_use_modules",
+   "can't use modules",
+   nullptr,
    0},
-  {STATS_CANTUSEMODULES, "could_not_use_modules", "can't use modules", NULL, 0},
   {STATS_COMPILER,
    "could_not_find_compiler",
    "couldn't find the compiler",
-   NULL,
+   nullptr,
    0},
-  {STATS_MISSING, "missing_cache_file", "cache file missing", NULL, 0},
-  {STATS_ARGS, "bad_compiler_arguments", "bad compiler arguments", NULL, 0},
+  {STATS_MISSING, "missing_cache_file", "cache file missing", nullptr, 0},
+  {STATS_ARGS, "bad_compiler_arguments", "bad compiler arguments", nullptr, 0},
   {STATS_SOURCELANG,
    "unsupported_source_language",
    "unsupported source language",
-   NULL,
+   nullptr,
+   0},
+  {STATS_COMPCHECK,
+   "compiler_check_failed",
+   "compiler check failed",
+   nullptr,
    0},
-  {STATS_COMPCHECK, "compiler_check_failed", "compiler check failed", NULL, 0},
-  {STATS_CONFTEST, "autoconf_test", "autoconf compile/link", NULL, 0},
+  {STATS_CONFTEST, "autoconf_test", "autoconf compile/link", nullptr, 0},
   {STATS_UNSUPPORTED_OPTION,
    "unsupported_compiler_option",
    "unsupported compiler option",
-   NULL,
+   nullptr,
    0},
   {STATS_UNSUPPORTED_DIRECTIVE,
    "unsupported_code_directive",
    "unsupported code directive",
-   NULL,
+   nullptr,
    0},
-  {STATS_OUTSTDOUT, "output_to_stdout", "output to stdout", NULL, 0},
+  {STATS_OUTSTDOUT, "output_to_stdout", "output to stdout", nullptr, 0},
   {STATS_BADOUTPUTFILE,
    "bad_output_file",
    "could not write to output file",
-   NULL,
+   nullptr,
    0},
-  {STATS_NOINPUT, "no_input_file", "no input file", NULL, 0},
+  {STATS_NOINPUT, "no_input_file", "no input file", nullptr, 0},
   {STATS_BADEXTRAFILE,
    "error_hashing_extra_file",
    "error hashing extra file",
-   NULL,
+   nullptr,
    0},
   {STATS_NUMCLEANUPS,
    "cleanups_performed",
    "cleanups performed",
-   NULL,
+   nullptr,
    FLAG_ALWAYS},
   {STATS_NUMFILES,
    "files_in_cache",
    "files in cache",
-   NULL,
+   nullptr,
    FLAG_NOZERO | FLAG_ALWAYS},
   {STATS_TOTALSIZE,
    "cache_size_kibibyte",
@@ -168,14 +180,14 @@ static struct
   {STATS_OBSOLETE_MAXFILES,
    "OBSOLETE",
    "OBSOLETE",
-   NULL,
+   nullptr,
    FLAG_NOZERO | FLAG_NEVER},
   {STATS_OBSOLETE_MAXSIZE,
    "OBSOLETE",
    "OBSOLETE",
-   NULL,
+   nullptr,
    FLAG_NOZERO | FLAG_NEVER},
-  {STATS_NONE, NULL, NULL, NULL, 0}};
+  {STATS_NONE, nullptr, nullptr, nullptr, 0}};
 
 static char*
 format_size(uint64_t size)
@@ -201,7 +213,7 @@ format_timestamp(uint64_t timestamp)
     strftime(buffer, sizeof(buffer), "%c", &tm);
     return format("    %s", buffer);
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -350,10 +362,9 @@ stats_flush_to_file(const Config& config,
   }
 
   if (!config.log_file().empty() || config.debug()) {
-    for (int i = 0; i < STATS_END; ++i) {
-      if (updates->data[stats_info[i].stat] != 0
-          && !(stats_info[i].flags & FLAG_NOZERO)) {
-        cc_log("Result: %s", stats_info[i].message);
+    for (auto& info : stats_info) {
+      if (updates->data[info.stat] != 0 && !(info.flags & FLAG_NOZERO)) {
+        cc_log("Result: %s", info.message);
       }
     }
   }
@@ -527,7 +538,7 @@ stats_zero(const Config& config)
   x_unlink(fname);
   free(fname);
 
-  time_t timestamp = time(NULL);
+  time_t timestamp = time(nullptr);
 
   for (int dir = 0; dir <= 0xF; dir++) {
     struct counters* counters = counters_init(STATS_END);
index cc6c67087251dca76b156b98f611b4a33a44018d..b3626d3210d09a07ec4b89492b45a6db54cc1ec2 100644 (file)
@@ -144,9 +144,9 @@ typedef unsigned (*suite_fn)(unsigned);
 int cct_run(const suite_fn* suites, int verbose);
 
 void cct_suite_begin(const char* name);
-void cct_suite_end(void);
+void cct_suite_end();
 void cct_test_begin(const char* name);
-void cct_test_end(void);
+void cct_test_end();
 void cct_check_passed(const char* file, int line, const char* assertion);
 void cct_check_failed(const char* file,
                       int line,
index 3d07a6fb55d1bb1b9cbf1a793ab69adc7488bf50..7db9d7255622048636498f97358edfd770d06c60 100644 (file)
@@ -42,7 +42,7 @@ const suite_fn k_legacy_suites[] = {
   &suite_legacy_util,
   &suite_lockfile,
   &suite_stats,
-  NULL,
+  nullptr,
 };
 
 int
index 4eab5466f1b71c7cacd135b9cecb53286c0edcc5..c6fe00ca176e240ba59620dafadc204428d0d654 100644 (file)
@@ -90,8 +90,8 @@ TEST_CASE("Large compressible Compression::Type::zstd roundtrip")
 TEST_CASE("Large uncompressible Compression::Type::zstd roundtrip")
 {
   char data[100000];
-  for (size_t i = 0; i < sizeof(data); i++) {
-    data[i] = rand() % 256;
+  for (char& c : data) {
+    c = rand() % 256;
   }
 
   File f("data.zstd", "wb");
index 2d441021de7292e30e0321b6b474efc86757c135..0324a0911bf782ad7923d64dab65a85277f981de 100644 (file)
@@ -26,7 +26,7 @@ TEST_SUITE(args)
 
 TEST(args_init_empty)
 {
-  struct args* args = args_init(0, NULL);
+  struct args* args = args_init(0, nullptr);
   CHECK(args);
   CHECK_INT_EQ(0, args->argc);
   CHECK(!args->argv[0]);
index 31e90022e829c0e7e3be5c1c51df89aa617df6b9..86d5ce12fd46483ff0060e3928a3e855dbc141b5 100644 (file)
@@ -75,7 +75,7 @@ TEST(dash_E_should_result_in_called_for_preprocessing)
   struct args *preprocessed, *compiler;
 
   create_file("foo.c", "");
-  CHECK(process_args(ctx, orig, &preprocessed, NULL, &compiler)
+  CHECK(process_args(ctx, orig, &preprocessed, nullptr, &compiler)
         == STATS_PREPROCESSING);
 
   args_free(orig);
@@ -89,7 +89,7 @@ TEST(dash_M_should_be_unsupported)
   struct args *preprocessed, *compiler;
 
   create_file("foo.c", "");
-  CHECK(process_args(ctx, orig, &preprocessed, NULL, &compiler)
+  CHECK(process_args(ctx, orig, &preprocessed, nullptr, &compiler)
         == STATS_UNSUPPORTED_OPTION);
 
   args_free(orig);
@@ -105,12 +105,12 @@ TEST(dependency_args_to_preprocessor_if_run_second_cpp_is_false)
   struct args* orig =
     args_init_from_string("cc " DEP_ARGS " -c foo.c -o foo.o");
   struct args* exp_cpp = args_init_from_string("cc " DEP_ARGS);
-  struct args* exp_extra = args_init(0, NULL);
+  struct args* exp_extra = args_init(0, nullptr);
   struct args* exp_cc = args_init_from_string("cc -c");
 #undef DEP_ARGS
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
   create_file("foo.c", "");
 
   ctx.config.set_run_second_cpp(false);
@@ -135,9 +135,9 @@ TEST(dependency_args_to_compiler_if_run_second_cpp_is_true)
   struct args* exp_extra = args_init_from_string(DEP_ARGS);
   struct args* exp_cc = args_init_from_string("cc -c " DEP_ARGS);
 #undef DEP_ARGS
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
   create_file("foo.c", "");
 
   CHECK(!process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
@@ -163,13 +163,13 @@ TEST(cpp_only_args_to_preprocessor_if_run_second_cpp_is_false)
   struct args* orig =
     args_init_from_string("cc " CPP_ARGS " " DEP_ARGS " -c foo.c -o foo.o");
   struct args* exp_cpp = args_init_from_string("cc " CPP_ARGS " " DEP_ARGS);
-  struct args* exp_extra = args_init(0, NULL);
+  struct args* exp_extra = args_init(0, nullptr);
   struct args* exp_cc = args_init_from_string("cc -c");
 #undef DEP_ARGS
 #undef CPP_ARGS
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
   create_file("foo.c", "");
 
   ctx.config.set_run_second_cpp(false);
@@ -200,9 +200,9 @@ TEST(cpp_only_args_to_preprocessor_and_compiler_if_run_second_cpp_is_true)
   struct args* exp_cc = args_init_from_string("cc " CPP_ARGS " -c " DEP_ARGS);
 #undef DEP_ARGS
 #undef CPP_ARGS
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
   create_file("foo.c", "");
 
   CHECK(!process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
@@ -224,9 +224,9 @@ TEST(dependency_args_that_take_an_argument_should_not_require_space_delimiter)
   struct args* exp_extra = args_init_from_string(DEP_ARGS);
   struct args* exp_cc = args_init_from_string("cc -c " DEP_ARGS);
 #undef DEP_ARGS
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
   create_file("foo.c", "");
 
   CHECK(!process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
@@ -246,9 +246,9 @@ TEST(MQ_flag_should_not_be_added_if_run_second_cpp_is_true)
   struct args* exp_cpp = args_init_from_string("cc");
   struct args* exp_extra = args_init_from_string("-MD -MF foo.d");
   struct args* exp_cc = args_init_from_string("cc -c -MD -MF foo.d");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
   create_file("foo.c", "");
 
   CHECK(!process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
@@ -266,11 +266,11 @@ TEST(MQ_flag_should_be_added_if_run_second_cpp_is_false)
   struct args* orig =
     args_init_from_string("cc -c -MD foo.c -MF foo.d -o foo.o");
   struct args* exp_cpp = args_init_from_string("cc -MD -MF foo.d -MQ foo.o");
-  struct args* exp_extra = args_init(0, NULL);
+  struct args* exp_extra = args_init(0, nullptr);
   struct args* exp_cc = args_init_from_string("cc -c");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
   create_file("foo.c", "");
 
   ctx.config.set_run_second_cpp(false);
@@ -288,11 +288,11 @@ TEST(MF_should_be_added_if_run_second_cpp_is_false)
 
   struct args* orig = args_init_from_string("cc -c -MD foo.c -o foo.o");
   struct args* exp_cpp = args_init_from_string("cc -MD -MF foo.d -MQ foo.o");
-  struct args* exp_extra = args_init(0, NULL);
+  struct args* exp_extra = args_init(0, nullptr);
   struct args* exp_cc = args_init_from_string("cc -c");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -313,9 +313,9 @@ TEST(MF_should_not_be_added_if_run_second_cpp_is_true)
   struct args* exp_cpp = args_init_from_string("cc");
   struct args* exp_extra = args_init_from_string("-MD");
   struct args* exp_cc = args_init_from_string("cc -c -MD");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -335,9 +335,9 @@ TEST(equal_sign_after_MF_should_be_removed)
   struct args* exp_cpp = args_init_from_string("cc");
   struct args* exp_extra = args_init_from_string("-MFpath");
   struct args* exp_cc = args_init_from_string("cc -c -MFpath");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -355,9 +355,9 @@ TEST(sysroot_should_be_rewritten_if_basedir_is_used)
 
   char* arg_string;
   struct args* orig;
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
   ctx.config.set_base_dir(get_root());
@@ -380,9 +380,9 @@ TEST(sysroot_with_separate_argument_should_be_rewritten_if_basedir_is_used)
 
   char* arg_string;
   struct args* orig;
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
   ctx.config.set_base_dir(get_root());
@@ -408,9 +408,9 @@ TEST(MF_flag_with_immediate_argument_should_work_as_last_argument)
   struct args* exp_cpp = args_init_from_string("cc");
   struct args* exp_extra = args_init_from_string("-MMD -MT bar -MFfoo.d");
   struct args* exp_cc = args_init_from_string("cc -c -MMD -MT bar -MFfoo.d");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -433,9 +433,9 @@ TEST(MT_flag_with_immediate_argument_should_work_as_last_argument)
     args_init_from_string("-MMD -MFfoo.d -MT foo -MTbar");
   struct args* exp_cc =
     args_init_from_string("cc -c -MMD -MFfoo.d -MT foo -MTbar");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -458,9 +458,9 @@ TEST(MQ_flag_with_immediate_argument_should_work_as_last_argument)
     args_init_from_string("-MMD -MFfoo.d -MQ foo -MQbar");
   struct args* exp_cc =
     args_init_from_string("cc -c -MMD -MFfoo.d -MQ foo -MQbar");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -482,9 +482,9 @@ TEST(MQ_flag_without_immediate_argument_should_not_add_MQobj)
   struct args* exp_extra = args_init_from_string("-MD -MP -MFfoo.d -MQ foo.d");
   struct args* exp_cc =
     args_init_from_string("gcc -c -MD -MP -MFfoo.d -MQ foo.d");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -506,9 +506,9 @@ TEST(MT_flag_without_immediate_argument_should_not_add_MTobj)
   struct args* exp_extra = args_init_from_string("-MD -MP -MFfoo.d -MT foo.d");
   struct args* exp_cc =
     args_init_from_string("gcc -c -MD -MP -MFfoo.d -MT foo.d");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -530,9 +530,9 @@ TEST(MQ_flag_with_immediate_argument_should_not_add_MQobj)
   struct args* exp_extra = args_init_from_string("-MD -MP -MFfoo.d -MQfoo.d");
   struct args* exp_cc =
     args_init_from_string("gcc -c -MD -MP -MFfoo.d -MQfoo.d");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -554,9 +554,9 @@ TEST(MT_flag_with_immediate_argument_should_not_add_MQobj)
   struct args* exp_extra = args_init_from_string("-MD -MP -MFfoo.d -MTfoo.d");
   struct args* exp_cc =
     args_init_from_string("gcc -c -MD -MP -MFfoo.d -MTfoo.d");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -575,11 +575,11 @@ TEST(fprofile_flag_with_existing_dir_should_be_rewritten_to_real_path)
   struct args* orig =
     args_init_from_string("gcc -c -fprofile-generate=some/dir foo.c");
   struct args* exp_cpp = args_init_from_string("gcc");
-  struct args* exp_extra = args_init(0, NULL);
+  struct args* exp_extra = args_init(0, nullptr);
   struct args* exp_cc = args_init_from_string("gcc");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   char* s;
 
@@ -609,12 +609,12 @@ TEST(fprofile_flag_with_nonexistent_dir_should_not_be_rewritten)
     args_init_from_string("gcc -c -fprofile-generate=some/dir foo.c");
   struct args* exp_cpp =
     args_init_from_string("gcc -fprofile-generate=some/dir");
-  struct args* exp_extra = args_init(0, NULL);
+  struct args* exp_extra = args_init(0, nullptr);
   struct args* exp_cc =
     args_init_from_string("gcc -fprofile-generate=some/dir -c");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
 
@@ -632,9 +632,9 @@ TEST(isystem_flag_with_separate_arg_should_be_rewritten_if_basedir_is_used)
 
   char* arg_string;
   struct args* orig;
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
   ctx.config.set_base_dir(get_root());
@@ -657,9 +657,9 @@ TEST(isystem_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
   char* cwd;
   char* arg_string;
   struct args* orig;
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
   ctx.config.set_base_dir("/"); // posix
@@ -685,9 +685,9 @@ TEST(I_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
   char* cwd;
   char* arg_string;
   struct args* orig;
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
   ctx.config.set_base_dir(x_strdup("/")); // posix
@@ -712,11 +712,11 @@ TEST(debug_flag_order_with_known_option_first)
 
   struct args* orig = args_init_from_string("cc -g1 -gsplit-dwarf foo.c -c");
   struct args* exp_cpp = args_init_from_string("cc -g1 -gsplit-dwarf");
-  struct args* exp_extra = args_init(0, NULL);
+  struct args* exp_extra = args_init(0, nullptr);
   struct args* exp_cc = args_init_from_string("cc -g1 -gsplit-dwarf -c");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
   CHECK(!process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
@@ -733,11 +733,11 @@ TEST(debug_flag_order_with_known_option_last)
 
   struct args* orig = args_init_from_string("cc -gsplit-dwarf -g1 foo.c -c");
   struct args* exp_cpp = args_init_from_string("cc -gsplit-dwarf -g1");
-  struct args* exp_extra = args_init(0, NULL);
+  struct args* exp_extra = args_init(0, nullptr);
   struct args* exp_cc = args_init_from_string("cc -gsplit-dwarf -g1 -c");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
   CHECK(!process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
@@ -759,9 +759,9 @@ TEST(options_not_to_be_passed_to_the_preprocesor)
     " -Wa,foo -Werror -Xlinker fie -Xlinker,fum -Wno-error");
   struct args* exp_cc = args_init_from_string(
     "cc -g -Wa,foo -Werror -Xlinker fie -Xlinker,fum -Wno-error -DX -c");
-  struct args* act_cpp = NULL;
-  struct args* act_extra = NULL;
-  struct args* act_cc = NULL;
+  struct args* act_cpp = nullptr;
+  struct args* act_extra = nullptr;
+  struct args* act_cc = nullptr;
 
   create_file("foo.c", "");
   CHECK(!process_args(ctx, orig, &act_cpp, &act_extra, &act_cc));
index 6a331bc9cb69e735da93e668dbc57ba478cb2997..71ebfd476479b25105be4cc556a66512d60b2581 100644 (file)
 #include "../src/compopt.hpp"
 #include "framework.hpp"
 
+bool compopt_verify_sortedness_and_flags();
+
 TEST_SUITE(compopt)
 
 TEST(option_table_should_be_sorted)
 {
-  bool compopt_verify_sortedness_and_flags(void);
   CHECK(compopt_verify_sortedness_and_flags());
 }
 
index fb88e99a86335dd3c28e1c5b775f70056c319f77..3ddde80f1b49abeba514676e5c76dc403f1cae82 100644 (file)
@@ -127,7 +127,7 @@ TEST(parse_size_with_suffix)
 
 TEST(format_command)
 {
-  const char* argv[] = {"foo", "bar", NULL};
+  const char* argv[] = {"foo", "bar", nullptr};
 
   CHECK_STR_EQ_FREE2("foo bar\n", format_command(argv));
 }