]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
c99: Use //-style-comments
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 22 Jul 2016 16:22:52 +0000 (18:22 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 22 Jul 2016 16:22:52 +0000 (18:22 +0200)
41 files changed:
HACKING.txt
args.c
ccache.c
ccache.h
cleanup.c
compopt.c
compopt.h
conf.c
counters.c
counters.h
execute.c
exitfn.c
hash.c
hashutil.c
language.c
language.h
lockfile.c
macroskip.h
main.c
manifest.c
mdfour.c
murmurhashneutral2.c
stats.c
system.h
test.sh
test/framework.c
test/framework.h
test/main.c
test/test_args.c
test/test_argument_processing.c
test/test_compopt.c
test/test_conf.c
test/test_counters.c
test/test_hash.c
test/test_hashutil.c
test/test_lockfile.c
test/test_stats.c
test/test_util.c
test/util.c
unify.c
util.c

index aa0648493c552b7bac409791a55d65f349938396..0bca7472312e7363a118433ccb932a8bb0d022d4 100644 (file)
@@ -17,6 +17,7 @@ Code formatting
 * Use only lowercase names for functions and variables.
 * Use only uppercase names for enum items and (with some exceptions) macros.
 * Don't use typedefs for structs and enums.
+* Use //-style comments.
 
 Tip: Install the tool uncrustify <http://uncrustify.sourceforge.net> and then
 run "make uncrustify" to fix up source code formatting.
diff --git a/args.c b/args.c
index 655fdf32fa15198542706751c926da5e3537e709..a3cbc6911f42350bfee0e4484df5c00ecfe1d4a4 100644 (file)
--- a/args.c
+++ b/args.c
@@ -1,20 +1,19 @@
-/*
- * Copyright (C) 2002 Andrew Tridgell
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2002 Andrew Tridgell
+// Copyright (C) 2009-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 
@@ -58,9 +57,8 @@ args_init_from_gcc_atfile(const char *filename)
        char *pos, *argtext, *argpos, *argbuf;
        char quoting;
 
-       /* Used to track quoting state; if \0, we are not inside quotes. Otherwise
-        * stores the quoting character that started it, for matching the end
-        * quote */
+       // Used to track quoting state; if \0, we are not inside quotes. Otherwise
+       // stores the quoting character that started it, for matching the end quote.
        quoting = '\0';
 
        if (!(argtext = read_text_file(filename, 0))) {
@@ -104,10 +102,10 @@ args_init_from_gcc_atfile(const char *filename)
                        if (quoting) {
                                break;
                        }
-               /* Fall through */
+                       // Fall through.
 
                case '\0':
-                       /* end of token */
+                       // End of token
                        *argpos = '\0';
                        if (argbuf[0] != '\0') {
                                args_add(args, argbuf);
@@ -138,21 +136,20 @@ args_copy(struct args *args)
        return args_init(args->argc, args->argv);
 }
 
-/* Insert all arguments in src into dest at position index.
- * If replace is true, the element at dest->argv[index] is replaced
- * with the contents of src and everything past it is shifted.
- * Otherwise, dest->argv[index] is also shifted.
- *
- * src is consumed by this operation and should not be freed or used
- * again by the caller */
+// Insert all arguments in src into dest at position index. If replace is true,
+// the element at dest->argv[index] is replaced with the contents of src and
+// everything past it is shifted. Otherwise, dest->argv[index] is also shifted.
+//
+// src is consumed by this operation and should not be freed or used again by
+// the caller.
 void
 args_insert(struct args *dest, int index, struct args *src, bool replace)
 {
        int offset;
        int i;
 
-       /* Adjustments made if we are replacing or shifting the element
-        * currently at dest->argv[index] */
+       // Adjustments made if we are replacing or shifting the element currently at
+       // dest->argv[index].
        offset = replace ? 1 : 0;
 
        if (replace) {
@@ -161,8 +158,8 @@ args_insert(struct args *dest, int index, struct args *src, bool replace)
 
        if (src->argc == 0) {
                if (replace) {
-                       /* Have to shift everything down by 1 since
-                        * we replaced with an empty list */
+                       // Have to shift everything down by 1 since we replaced with an empty
+                       // list.
                        for (i = index; i < dest->argc; i++) {
                                dest->argv[i] = dest->argv[i + 1];
                        }
@@ -173,7 +170,7 @@ args_insert(struct args *dest, int index, struct args *src, bool replace)
        }
 
        if (src->argc == 1 && replace) {
-               /* Trivial case; replace with 1 element */
+               // Trivial case; replace with 1 element.
                dest->argv[index] = src->argv[0];
                src->argc = 0;
                args_free(src);
@@ -185,12 +182,12 @@ args_insert(struct args *dest, int index, struct args *src, bool replace)
          (src->argc + dest->argc + 1 - offset) *
          sizeof(char *));
 
-       /* Shift arguments over */
+       // Shift arguments over.
        for (i = dest->argc; i >= index + offset; i--) {
                dest->argv[i + src->argc - offset] = dest->argv[i];
        }
 
-       /* Copy the new arguments into place */
+       // Copy the new arguments into place.
        for (i = 0; i < src->argc; i++) {
                dest->argv[i + index] = src->argv[i];
        }
@@ -226,7 +223,7 @@ args_add(struct args *args, const char *s)
        args->argv[args->argc] = NULL;
 }
 
-/* Add all arguments in to_append to args. */
+// Add all arguments in to_append to args.
 void
 args_extend(struct args *args, struct args *to_append)
 {
@@ -236,7 +233,7 @@ args_extend(struct args *args, struct args *to_append)
        }
 }
 
-/* pop the last element off the args list */
+// Pop the last element off the args list.
 void
 args_pop(struct args *args, int n)
 {
@@ -247,7 +244,7 @@ args_pop(struct args *args, int n)
        }
 }
 
-/* set argument at given index */
+// Set argument at given index.
 void
 args_set(struct args *args, int index, const char *value)
 {
@@ -256,7 +253,7 @@ args_set(struct args *args, int index, const char *value)
        args->argv[index] = x_strdup(value);
 }
 
-/* remove the first element of the argument list */
+// Remove the first element of the argument list.
 void
 args_remove_first(struct args *args)
 {
@@ -265,7 +262,7 @@ args_remove_first(struct args *args)
        args->argc--;
 }
 
-/* add an argument into the front of the argument list */
+// Add an argument into the front of the argument list.
 void
 args_add_prefix(struct args *args, const char *s)
 {
@@ -277,7 +274,7 @@ args_add_prefix(struct args *args, const char *s)
        args->argc++;
 }
 
-/* strip any arguments beginning with the specified prefix */
+// Strip any arguments beginning with the specified prefix.
 void
 args_strip(struct args *args, const char *prefix)
 {
@@ -295,10 +292,8 @@ args_strip(struct args *args, const char *prefix)
        }
 }
 
-/*
- * Format args to a space-separated string. Does not quote spaces. Caller
- * frees.
- */
+// Format args to a space-separated string. Does not quote spaces. Caller
+// frees.
 char *
 args_to_string(struct args *args)
 {
@@ -318,7 +313,7 @@ args_to_string(struct args *args)
        return result;
 }
 
-/* Returns true if args1 equals args2, else false. */
+// Returns true if args1 equals args2, else false.
 bool
 args_equal(struct args *args1, struct args *args2)
 {
@@ -333,4 +328,3 @@ args_equal(struct args *args1, struct args *args2)
        }
        return true;
 }
-
index 74165f676110371c7a8b857e8a6e6d552b2326ea..a20fe5e31a912c11fb642cedd6be6414002b90f7 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -1,23 +1,21 @@
-/*
- * ccache -- a fast C/C++ compiler cache
- *
- * Copyright (C) 2002-2007 Andrew Tridgell
- * Copyright (C) 2009-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// ccache -- a fast C/C++ compiler cache
+//
+// Copyright (C) 2002-2007 Andrew Tridgell
+// Copyright (C) 2009-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 #include "compopt.h"
@@ -71,179 +69,146 @@ static const char USAGE_TEXT[] =
   "\n"
   "See also <https://ccache.samba.org>.\n";
 
-/* Global configuration data. */
+// Global configuration data.
 struct conf *conf = NULL;
 
-/* Where to write configuration changes. */
+// Where to write configuration changes.
 char *primary_config_path = NULL;
 
-/* Secondary, read-only configuration file (if any). */
+// Secondary, read-only configuration file (if any).
 char *secondary_config_path = NULL;
 
-/* current working directory taken from $PWD, or getcwd() if $PWD is bad */
+// Current working directory taken from $PWD, or getcwd() if $PWD is bad.
 char *current_working_dir = NULL;
 
-/* the original argument list */
+// The original argument list.
 static struct args *orig_args;
 
-/* the source file */
+// The source file.
 static char *input_file;
 
-/* The output file being compiled to. */
+// The output file being compiled to.
 static char *output_obj;
 
-/* The path to the dependency file (implicit or specified with -MF). */
+// The path to the dependency file (implicit or specified with -MF).
 static char *output_dep;
 
-/* The path to the coverage file (implicit when using -ftest-coverage). */
+// The path to the coverage file (implicit when using -ftest-coverage).
 static char *output_cov;
 
-/* Diagnostic generation information (clang). Contains pathname if not
- * NULL. */
+// Diagnostic generation information (clang). Contains pathname if not NULL.
 static char *output_dia = NULL;
 
-/* -gsplit-dwarf support: Split dwarf information (GCC 4.8 and
- *  up). Contains pathname if not NULL. */
+// Split dwarf information (GCC 4.8 andup). Contains pathname if not NULL.
 static char *output_dwo = NULL;
 
-/* Array for storing -arch options. */
+// Array for storing -arch options.
 #define MAX_ARCH_ARGS 10
 static size_t arch_args_size = 0;
 static char *arch_args[MAX_ARCH_ARGS] = {NULL};
 
-/*
- * Name (represented as a struct file_hash) of the file containing the cached
- * object code.
- */
+// Name (represented as a struct file_hash) of the file containing the cached
+// object code.
 static struct file_hash *cached_obj_hash;
 
-/*
- * Full path to the file containing the cached object code
- * (cachedir/a/b/cdef[...]-size.o).
- */
+// Full path to the file containing the cached object code
+// (cachedir/a/b/cdef[...]-size.o).
 static char *cached_obj;
 
-/*
- * Full path to the file containing the standard error output
- * (cachedir/a/b/cdef[...]-size.stderr).
- */
+// Full path to the file containing the standard error output
+// (cachedir/a/b/cdef[...]-size.stderr).
 static char *cached_stderr;
 
-/*
- * Full path to the file containing the dependency information
- * (cachedir/a/b/cdef[...]-size.d).
- */
+// Full path to the file containing the dependency information
+// (cachedir/a/b/cdef[...]-size.d).
 static char *cached_dep;
 
-/*
- * Full path to the file containing the coverage information
- * (cachedir/a/b/cdef[...]-size.gcno).
- */
+// Full path to the file containing the coverage information
+// (cachedir/a/b/cdef[...]-size.gcno).
 static char *cached_cov;
 
-/*
- * Full path to the file containing the diagnostic information (for clang)
- * (cachedir/a/b/cdef[...]-size.dia).
- */
+// Full path to the file containing the diagnostic information (for clang)
+// (cachedir/a/b/cdef[...]-size.dia).
 static char *cached_dia;
 
-/*
- * -gsplit-dwarf support:
- * Full path to the file containing the split dwarf (for GCC 4.8 and
- * above)
- * (cachedir/a/b/cdef[...]-size.dwo).
- *
- * contains NULL if -gsplit-dwarf is not given.
- */
+// Full path to the file containing the split dwarf (for GCC 4.8 and above)
+// (cachedir/a/b/cdef[...]-size.dwo).
+//
+// Contains NULL if -gsplit-dwarf is not given.
 static char *cached_dwo;
 
-/*
- * -gsplit-dwarf support:
- * using_split_dwarf is true if "-gsplit-dwarf" is given to the
- * compiler (GCC 4.8 and up).
- */
+// using_split_dwarf is true if "-gsplit-dwarf" is given to the compiler (GCC
+// 4.8 and up).
 bool using_split_dwarf = false;
 
-/*
- * Full path to the file containing the manifest
- * (cachedir/a/b/cdef[...]-size.manifest).
- */
+// Full path to the file containing the manifest
+// (cachedir/a/b/cdef[...]-size.manifest).
 static char *manifest_path;
 
-/*
- * Time of compilation. Used to see if include files have changed after
- * compilation.
- */
+// Time of compilation. Used to see if include files have changed after
+// compilation.
 time_t time_of_compilation;
 
-/*
- * Files included by the preprocessor and their hashes/sizes. Key: file path.
- * Value: struct file_hash.
- */
+// Files included by the preprocessor and their hashes/sizes. Key: file path.
+// Value: struct file_hash.
 static struct hashtable *included_files = NULL;
 
-/* uses absolute path for some include files */
+// Uses absolute path for some include files.
 static bool has_absolute_include_headers = false;
 
-/* List of headers to ignore */
+// List of headers to ignore.
 static char **ignore_headers;
 
-/* Size of headers to ignore list */
+// Size of headers to ignore list.
 static size_t ignore_headers_len;
 
-/* is gcc being asked to output debug info? */
+// Is the compiler being asked to output debug info?
 static bool generating_debuginfo;
 
-/* is gcc being asked to output dependencies? */
+// Is the compiler being asked to output dependencies?
 static bool generating_dependencies;
 
-/* is gcc being asked to output coverage? */
+// Is the compiler being asked to output coverage?
 static bool generating_coverage;
 
-/* relocating debuginfo, in the format old=new */
+// Relocating debuginfo in the format old=new.
 static char *debug_prefix_map = NULL;
 
-/* is gcc being asked to output coverage data (.gcda) at runtime? */
+// Is the compiler being asked to output coverage data (.gcda) at runtime?
 static bool profile_arcs;
 
-/* name of the custom profile directory (default: object dirname) */
+// Name of the custom profile directory (default: object dirname).
 static char *profile_dir;
 
-/* the name of the temporary pre-processor file */
+// The name of the temporary preprocessed file.
 static char *i_tmpfile;
 
-/* are we compiling a .i or .ii file directly? */
+// Are we compiling a .i or .ii file directly?
 static bool direct_i_file;
 
-/* the name of the cpp stderr file */
+// The name of the cpp stderr file.
 static char *cpp_stderr;
 
-/*
- * Full path to the statistics file in the subdirectory where the cached result
- * belongs (<cache_dir>/<x>/stats).
- */
+// Full path to the statistics file in the subdirectory where the cached result
+// belongs (<cache_dir>/<x>/stats).
 char *stats_file = NULL;
 
-/* Whether the output is a precompiled header */
+// Whether the output is a precompiled header.
 static bool output_is_precompiled_header = false;
 
-/* Profile generation / usage information */
+// Profile generation / usage information.
 static char *profile_dir = NULL;
 static bool profile_use = false;
 static bool profile_generate = false;
 
-/*
- * Whether we are using a precompiled header (either via -include, #include or
- * clang's -include-pch or -include-pth).
- */
+// Whether we are using a precompiled header (either via -include, #include or
+// clang's -include-pch or -include-pth).
 static bool using_precompiled_header = false;
 
-/*
- * The .gch/.pch/.pth file used for compilation.
- */
+// The .gch/.pch/.pth file used for compilation.
 static char *included_pch_file = NULL;
 
-/* How long (in microseconds) to wait before breaking a stale lock. */
+// How long (in microseconds) to wait before breaking a stale lock.
 unsigned lock_staleness_limit = 2000000;
 
 enum fromcache_call_mode {
@@ -256,24 +221,22 @@ struct pending_tmp_file {
        struct pending_tmp_file *next;
 };
 
-/* Temporary files to remove at program exit. */
+// Temporary files to remove at program exit.
 static struct pending_tmp_file *pending_tmp_files = NULL;
 
 #ifndef _WIN32
 static sigset_t fatal_signal_set;
 
-/* PID of currently executing compiler that we have started, if any. 0 means no
- * ongoing compilation. */
+// PID of currently executing compiler that we have started, if any. 0 means no
+// ongoing compilation.
 static pid_t compiler_pid = 0;
 #endif
 
-/*
- * This is a string that identifies the current "version" of the hash sum
- * computed by ccache. If, for any reason, we want to force the hash sum to be
- * different for the same input in a new ccache version, we can just change
- * this string. A typical example would be if the format of one of the files
- * stored in the cache changes in a backwards-incompatible way.
- */
+// This is a string that identifies the current "version" of the hash sum
+// computed by ccache. If, for any reason, we want to force the hash sum to be
+// different for the same input in a new ccache version, we can just change
+// this string. A typical example would be if the format of one of the files
+// stored in the cache changes in a backwards-incompatible way.
 static const char HASH_PREFIX[] = "3";
 
 static void
@@ -312,7 +275,7 @@ add_prefix(struct args *args, char *prefix_command)
        args_free(prefix);
 }
 
-/* Something went badly wrong - just execute the real compiler. */
+// Something went badly wrong - just execute the real compiler.
 static void
 failed(void)
 {
@@ -333,7 +296,7 @@ temp_dir()
 {
        static char *path = NULL;
        if (path) {
-               return path; /* Memoize */
+               return path; // Memoize
        }
        path = conf->temporary_dir;
        if (str_eq(path, "")) {
@@ -378,11 +341,11 @@ do_clean_up_pending_tmp_files(void)
 {
        struct pending_tmp_file *p = pending_tmp_files;
        while (p) {
-               /* Can't call tmp_unlink here since its cc_log calls aren't signal safe. */
+               // Can't call tmp_unlink here since its cc_log calls aren't signal safe.
                unlink(p->path);
                p = p->next;
-               /* Leak p->path and p here because clean_up_pending_tmp_files needs to be
-                * signal safe. */
+               // Leak p->path and p here because clean_up_pending_tmp_files needs to be
+               // signal safe.
        }
 }
 
@@ -398,12 +361,12 @@ clean_up_pending_tmp_files(void)
 static void
 signal_handler(int signum)
 {
-       /* Unregister handler for this signal so that we can send the signal to
-        * ourselves at the end of the handler. */
+       // Unregister handler for this signal so that we can send the signal to
+       // ourselves at the end of the handler.
        signal(signum, SIG_DFL);
 
-       /* If ccache was killed explicitly, then bring the compiler subprocess (if
-        * any) with us as well. */
+       // 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) {
@@ -413,12 +376,12 @@ signal_handler(int signum)
        do_clean_up_pending_tmp_files();
 
        if (compiler_pid != 0) {
-               /* Wait for compiler subprocess to exit before we snuff it. */
+               // Wait for compiler subprocess to exit before we snuff it.
                waitpid(compiler_pid, NULL, 0);
        }
 
-       /* Resend signal to ourselves to exit properly after returning from the
-        * handler. */
+       // Resend signal to ourselves to exit properly after returning from the
+       // handler.
        kill(getpid(), signum);
 }
 
@@ -457,7 +420,7 @@ set_up_signal_handlers(void)
        register_signal_handler(SIGQUIT);
 #endif
 }
-#endif /* _WIN32 */
+#endif // _WIN32
 
 static void
 clean_up_internal_tempdir(void)
@@ -468,7 +431,7 @@ clean_up_internal_tempdir(void)
        time_t now = time(NULL);
 
        if (x_stat(conf->cache_dir, &st) != 0 || st.st_mtime + 3600 >= now) {
-               /* No cleanup needed. */
+               // No cleanup needed.
                return;
        }
 
@@ -514,10 +477,8 @@ get_current_working_dir(void)
        return current_working_dir;
 }
 
-/*
- * Transform a name to a full path into the cache directory, creating needed
- * sublevels if needed. Caller frees.
- */
+// Transform a name to a full path into the cache directory, creating needed
+// sublevels if needed. Caller frees.
 static char *
 get_path_in_cache(const char *name, const char *suffix)
 {
@@ -537,11 +498,9 @@ get_path_in_cache(const char *name, const char *suffix)
        return result;
 }
 
-/*
- * This function hashes an include file and stores the path and hash in the
- * global included_files variable. If the include file is a PCH, cpp_hash is
- * also updated. Takes over ownership of path.
- */
+// This function hashes an include file and stores the path and hash in the
+// global included_files variable. If the include file is a PCH, cpp_hash is
+// also updated. Takes over ownership of path.
 static void
 remember_include_file(char *path, struct mdfour *cpp_hash, bool system)
 {
@@ -561,27 +520,27 @@ remember_include_file(char *path, struct mdfour *cpp_hash, bool system)
        size_t i;
 
        if (path_len >= 2 && (path[0] == '<' && path[path_len - 1] == '>')) {
-               /* Typically <built-in> or <command-line>. */
+               // Typically <built-in> or <command-line>.
                goto ignore;
        }
 
        if (str_eq(path, input_file)) {
-               /* Don't remember the input file. */
+               // Don't remember the input file.
                goto ignore;
        }
 
        if (system && (conf->sloppiness & SLOPPY_NO_SYSTEM_HEADERS)) {
-               /* Don't remember this system header. */
+               // Don't remember this system header.
                goto ignore;
        }
 
        if (hashtable_search(included_files, path)) {
-               /* Already known include file. */
+               // Already known include file.
                goto ignore;
        }
 
 #ifdef _WIN32
-       /* stat fails on directories on win32 */
+       // stat fails on directories on win32.
        attributes = GetFileAttributes(path);
        if (attributes != INVALID_FILE_ATTRIBUTES &&
            attributes & FILE_ATTRIBUTE_DIRECTORY) {
@@ -593,16 +552,16 @@ remember_include_file(char *path, struct mdfour *cpp_hash, bool system)
                goto failure;
        }
        if (S_ISDIR(st.st_mode)) {
-               /* Ignore directory, typically $PWD. */
+               // Ignore directory, typically $PWD.
                goto ignore;
        }
        if (!S_ISREG(st.st_mode)) {
-               /* Device, pipe, socket or other strange creature. */
+               // Device, pipe, socket or other strange creature.
                cc_log("Non-regular include file %s", path);
                goto failure;
        }
 
-       /* canonicalize path for comparison, clang uses ./header.h */
+       // Canonicalize path for comparison; clang uses ./header.h.
        canonical = path;
        canonical_len = path_len;
        if (canonical[0] == '.' && canonical[1] == '/') {
@@ -624,7 +583,7 @@ remember_include_file(char *path, struct mdfour *cpp_hash, bool system)
                }
        }
 
-       /* Let's hash the include file. */
+       // Let's hash the include file.
        if (!(conf->sloppiness & SLOPPY_INCLUDE_FILE_MTIME)
            && st.st_mtime >= time_of_compilation) {
                cc_log("Include file %s too new", path);
@@ -653,7 +612,7 @@ remember_include_file(char *path, struct mdfour *cpp_hash, bool system)
        if (conf->direct_mode) {
                struct file_hash *h;
 
-               if (!is_pch) { /* else: the file has already been hashed. */
+               if (!is_pch) { // else: the file has already been hashed.
                        int result;
 
                        if (st.st_size > 0) {
@@ -688,16 +647,14 @@ failure:
                cc_log("Disabling direct mode");
                conf->direct_mode = false;
        }
-       /* Fall through. */
+       // Fall through.
 ignore:
        free(path);
        free(source);
 }
 
-/*
- * Make a relative path from current working directory to path if path is under
- * the base directory. Takes over ownership of path. Caller frees.
- */
+// Make a relative path from current working directory to path if path is under
+// the base directory. Takes over ownership of path. Caller frees.
 static char *
 make_relative_path(char *path)
 {
@@ -710,20 +667,20 @@ make_relative_path(char *path)
 
 #ifdef _WIN32
        if (path[0] == '/') {
-               path++;  /* skip leading slash */
+               path++;  // Skip leading slash.
        }
 #endif
 
-       /* x_realpath only works for existing paths, so if path doesn't exist, try
-        * dirname(path) and assemble the path afterwards. We only bother to try
-        * canonicalizing one of these two paths since a compiler path argument
-        * typically only makes sense if path or dirname(path) exists. */
+       // x_realpath only works for existing paths, so if path doesn't exist, try
+       // dirname(path) and assemble the path afterwards. We only bother to try
+       // canonicalizing one of these two paths since a compiler path argument
+       // typically only makes sense if path or dirname(path) exists.
        if (stat(path, &st) != 0) {
-               /* path doesn't exist. */
+               // path doesn't exist.
                char *dir, *p;
                dir = dirname(path);
                if (stat(dir, &st) != 0) {
-                       /* And neither does its parent directory, so no action to take. */
+                       // And neither does its parent directory, so no action to take.
                        free(dir);
                        return path;
                }
@@ -749,21 +706,19 @@ make_relative_path(char *path)
                        return relpath;
                }
        } else {
-               /* path doesn't exist, so leave it as it is. */
+               // path doesn't exist, so leave it as it is.
                free(path_suffix);
                return path;
        }
 }
 
-/*
- * This function reads and hashes a file. While doing this, it also does these
- * things:
- *
- * - Makes include file paths for which the base directory is a prefix relative
- *   when computing the hash sum.
- * - Stores the paths and hashes of included files in the global variable
- *   included_files.
- */
+// This function reads and hashes a file. While doing this, it also does these
+// things:
+//
+// - Makes include file paths for which the base directory is a prefix relative
+//   when computing the hash sum.
+// - Stores the paths and hashes of included files in the global variable
+//   included_files.
 static bool
 process_preprocessed_file(struct mdfour *hash, const char *path)
 {
@@ -794,53 +749,51 @@ process_preprocessed_file(struct mdfour *hash, const char *path)
                included_files = create_hashtable(1000, hash_from_string, strings_equal);
        }
 
-       /* Bytes between p and q are pending to be hashed. */
+       // Bytes between p and q are pending to be hashed.
        end = data + size;
        p = data;
        q = data;
-       /* There must be at least 7 characters (# 1 "x") left to potentially find an
-        * include file path. */
+       // There must be at least 7 characters (# 1 "x") left to potentially find an
+       // include file path.
        while (q < end - 7) {
-               /*
-                * Check if we look at a line containing the file name of an included file.
-                * At least the following formats exist (where N is a positive integer):
-                *
-                * GCC:
-                *
-                *   # N "file"
-                *   # N "file" N
-                *   #pragma GCC pch_preprocess "file"
-                *
-                * HP's compiler:
-                *
-                *   #line N "file"
-                *
-                * AIX's compiler:
-                *
-                *   #line N "file"
-                *   #line N
-                *
-                * Note that there may be other lines starting with '#' left after
-                * preprocessing as well, for instance "#    pragma".
-                */
+               // Check if we look at a line containing the file name of an included file.
+               // At least the following formats exist (where N is a positive integer):
+               //
+               // GCC:
+               //
+               //   # N "file"
+               //   # N "file" N
+               //   #pragma GCC pch_preprocess "file"
+               //
+               // HP's compiler:
+               //
+               //   #line N "file"
+               //
+               // AIX's compiler:
+               //
+               //   #line N "file"
+               //   #line N
+               //
+               // Note that there may be other lines starting with '#' left after
+               // preprocessing as well, for instance "#    pragma".
                if (q[0] == '#'
-                   /* GCC: */
+                   // GCC:
                    && ((q[1] == ' ' && q[2] >= '0' && q[2] <= '9')
-                       /* GCC precompiled header: */
+                       // GCC precompiled header:
                        || (q[1] == 'p'
                            && str_startswith(&q[2], "ragma GCC pch_preprocess "))
-                       /* HP/AIX: */
+                       // HP/AIX:
                        || (q[1] == 'l' && q[2] == 'i' && q[3] == 'n' && q[4] == 'e'
                            && q[5] == ' '))
                    && (q == data || q[-1] == '\n')) {
                        char *path;
                        bool system;
 
-                       /* Workarounds for preprocessor linemarker bugs in GCC version 6 */
+                       // Workarounds for preprocessor linemarker bugs in GCC version 6.
                        if (q[2] == '3') {
                                if (str_startswith(q, "# 31 \"<command-line>\"\n")) {
-                                       /* Bogus extra line with #31, after the regular #1:
-                                          Ignore the whole line, and continue parsing */
+                                       // Bogus extra line with #31, after the regular #1: Ignore the whole
+                                       // line, and continue parsing.
                                        hash_buffer(hash, p, q - p);
                                        while (q < end && *q != '\n') {
                                                q++;
@@ -849,8 +802,8 @@ process_preprocessed_file(struct mdfour *hash, const char *path)
                                        p = q;
                                        continue;
                                } else if (str_startswith(q, "# 32 \"<command-line>\" 2\n")) {
-                                       /* Bogus wrong line with #32, instead of regular #1:
-                                          Replace the line number with the usual one */
+                                       // Bogus wrong line with #32, instead of regular #1: Replace the line
+                                       // number with the usual one.
                                        hash_buffer(hash, p, q - p);
                                        q += 1;
                                        q[0] = '#';
@@ -864,7 +817,7 @@ process_preprocessed_file(struct mdfour *hash, const char *path)
                                q++;
                        }
                        if (q < end && *q == '\n') {
-                               /* A newline before the quotation mark -> no match. */
+                               // A newline before the quotation mark -> no match.
                                continue;
                        }
                        q++;
@@ -873,22 +826,22 @@ process_preprocessed_file(struct mdfour *hash, const char *path)
                                free(data);
                                return false;
                        }
-                       /* q points to the beginning of an include file path */
+                       // q points to the beginning of an include file path
                        hash_buffer(hash, p, q - p);
                        p = q;
                        while (q < end && *q != '"') {
                                q++;
                        }
-                       /* look for preprocessor flags, after the "filename" */
+                       // Look for preprocessor flags, after the "filename".
                        system = false;
                        r = q + 1;
                        while (r < end && *r != '\n') {
-                               if (*r == '3') { /* system header */
+                               if (*r == '3') { // system header
                                        system = true;
                                }
                                r++;
                        }
-                       /* p and q span the include file path */
+                       // p and q span the include file path.
                        path = x_strndup(p, q - p);
                        if (!has_absolute_include_headers) {
                                has_absolute_include_headers = is_absolute_path(path);
@@ -904,8 +857,8 @@ process_preprocessed_file(struct mdfour *hash, const char *path)
        hash_buffer(hash, p, (end - p));
        free(data);
 
-       /* Explicitly check the .gch/.pch/.pth file, Clang does not include any
-        * mention of it in the preprocessed output. */
+       // Explicitly check the .gch/.pch/.pth file, Clang does not include any
+       // mention of it in the preprocessed output.
        if (included_pch_file) {
                char *path = x_strdup(included_pch_file);
                path = make_relative_path(path);
@@ -916,9 +869,7 @@ process_preprocessed_file(struct mdfour *hash, const char *path)
        return true;
 }
 
-/*
- * Replace absolute paths with relative paths in the provided dependency file.
- */
+// Replace absolute paths with relative paths in the provided dependency file.
 static void
 use_relative_paths_in_depfile(const char *depfile)
 {
@@ -931,12 +882,12 @@ use_relative_paths_in_depfile(const char *depfile)
 
        if (str_eq(conf->base_dir, "")) {
                cc_log("Base dir not set, skip using relative paths");
-               return; /* nothing to do */
+               return; // nothing to do
        }
        if (!has_absolute_include_headers) {
                cc_log("No absolute path for included files found, skip using relative"
                       " paths");
-               return; /* nothing to do */
+               return; // nothing to do
        }
 
        f = fopen(depfile, "r");
@@ -956,7 +907,7 @@ use_relative_paths_in_depfile(const char *depfile)
                        } else {
                                relpath = token;
                        }
-                       if (token != buf) { /* this is a dependency file */
+                       if (token != buf) { // this is a dependency file
                                fputc(' ', tmpf);
                        }
                        fputs(relpath, tmpf);
@@ -999,7 +950,7 @@ out:
        free(tmp_file);
 }
 
-/* Copy or link a file to the cache. */
+// Copy or link a file to the cache.
 static void
 put_file_in_cache(const char *source, const char *dest)
 {
@@ -1036,7 +987,7 @@ put_file_in_cache(const char *source, const char *dest)
        stats_update_size(file_size(&st), 1);
 }
 
-/* Copy or link a file from the cache. */
+// Copy or link a file from the cache.
 static void
 get_file_from_cache(const char *source, const char *dest)
 {
@@ -1052,7 +1003,7 @@ get_file_from_cache(const char *source, const char *dest)
 
        if (ret == -1) {
                if (errno == ENOENT || errno == ESTALE) {
-                       /* Someone removed the file just before we began copying? */
+                       // Someone removed the file just before we began copying?
                        cc_log("Cache file %s just disappeared from cache", source);
                        stats_update(STATS_MISSING);
                } else {
@@ -1064,8 +1015,8 @@ get_file_from_cache(const char *source, const char *dest)
                        stats_update(STATS_ERROR);
                }
 
-               /* If there was trouble getting a file from the cached result, wipe the
-                * whole cached result for consistency. */
+               // If there was trouble getting a file from the cached result, wipe the
+               // whole cached result for consistency.
                x_unlink(cached_stderr);
                x_unlink(cached_obj);
                x_unlink(cached_dep);
@@ -1077,7 +1028,7 @@ get_file_from_cache(const char *source, const char *dest)
        cc_log("Created from cache: %s -> %s", source, dest);
 }
 
-/* Send cached stderr, if any, to stderr. */
+// Send cached stderr, if any, to stderr.
 static void
 send_cached_stderr(void)
 {
@@ -1088,11 +1039,11 @@ send_cached_stderr(void)
        }
 }
 
-/* Create or update the manifest file. */
+// Create or update the manifest file.
 void update_manifest_file(void)
 {
        struct stat st;
-       size_t old_size = 0; /* in bytes */
+       size_t old_size = 0; // in bytes
 
        if (!conf->direct_mode
            || !included_files
@@ -1115,7 +1066,7 @@ void update_manifest_file(void)
        }
 }
 
-/* run the real compiler and put the result in cache */
+// Run the real compiler and put the result in cache.
 static void
 to_cache(struct args *args)
 {
@@ -1131,7 +1082,7 @@ to_cache(struct args *args)
 
        if (generating_coverage) {
                char *tmp_aux;
-               /* gcc has some funny rule about max extension length */
+               // GCC has some funny rule about max extension length.
                if (strlen(get_extension(output_obj)) < 6) {
                        tmp_aux = remove_extension(output_obj);
                } else {
@@ -1143,10 +1094,9 @@ to_cache(struct args *args)
                tmp_cov = NULL;
        }
 
-       /* GCC (at least 4.8 and 4.9) forms the .dwo file name by removing everything
-        * after (and including) the last "." from the object file name and then
-        * appending ".dwo".
-        */
+       // GCC (at least 4.8 and 4.9) forms the .dwo file name by removing everything
+       // after (and including) the last "." from the object file name and then
+       // appending ".dwo".
        if (using_split_dwarf) {
                char *base_name = remove_extension(output_obj);
                tmp_dwo = format("%s.dwo", base_name);
@@ -1161,11 +1111,10 @@ to_cache(struct args *args)
                args_add(args, output_dia);
        }
 
-       /* Turn off DEPENDENCIES_OUTPUT when running cc1, because
-        * otherwise it will emit a line like
-        *
-        *  tmp.stdout.vexed.732.o: /home/mbp/.ccache/tmp.stdout.vexed.732.i
-        */
+       // Turn off DEPENDENCIES_OUTPUT when running cc1, because otherwise it will
+       // emit a line like this:
+       //
+       //   tmp.stdout.vexed.732.o: /home/mbp/.ccache/tmp.stdout.vexed.732.i
        x_unsetenv("DEPENDENCIES_OUTPUT");
 
        if (conf->run_second_cpp) {
@@ -1179,7 +1128,7 @@ to_cache(struct args *args)
        args_pop(args, 3);
 
        if (x_stat(tmp_stdout, &st) != 0) {
-               /* The stdout file was removed - cleanup in progress? Better bail out. */
+               // The stdout file was removed - cleanup in progress? Better bail out.
                stats_update(STATS_MISSING);
                tmp_unlink(tmp_stdout);
                tmp_unlink(tmp_stderr);
@@ -1202,10 +1151,8 @@ to_cache(struct args *args)
        }
        tmp_unlink(tmp_stdout);
 
-       /*
-        * Merge stderr from the preprocessor (if any) and stderr from the real
-        * compiler into tmp_stderr.
-        */
+       // Merge stderr from the preprocessor (if any) and stderr from the real
+       // compiler into tmp_stderr.
        if (cpp_stderr) {
                int fd_cpp_stderr;
                int fd_real_stderr;
@@ -1249,7 +1196,7 @@ to_cache(struct args *args)
 
                fd = open(tmp_stderr, O_RDONLY | O_BINARY);
                if (fd != -1) {
-                       /* We can output stderr immediately instead of rerunning the compiler. */
+                       // We can output stderr immediately instead of rerunning the compiler.
                        copy_fd(fd, 2);
                        close(fd);
                        tmp_unlink(tmp_stderr);
@@ -1305,20 +1252,20 @@ to_cache(struct args *args)
                }
                cc_log("Stored in cache: %s", cached_stderr);
                if (!conf->compression
-                   /* If the file was compressed, obtain the size again: */
+                   // If the file was compressed, obtain the size again:
                    || x_stat(cached_stderr, &st) == 0) {
                        stats_update_size(file_size(&st), 1);
                }
        } else {
                tmp_unlink(tmp_stderr);
                if (conf->recache) {
-                       /* If recaching, we need to remove any previous .stderr. */
+                       // If recaching, we need to remove any previous .stderr.
                        x_unlink(cached_stderr);
                }
        }
 
        if (generating_coverage) {
-               /* gcc won't generate notes if there is no code */
+               // GCC won't generate notes if there is no code.
                if (stat(tmp_cov, &st) != 0 && errno == ENOENT) {
                        FILE *f = fopen(cached_cov, "wb");
                        cc_log("Creating placeholder: %s", cached_cov);
@@ -1358,10 +1305,9 @@ to_cache(struct args *args)
        }
        stats_update(STATS_TOCACHE);
 
-       /* Make sure we have a CACHEDIR.TAG in the cache part of cache_dir. This can
-        * be done almost anywhere, but we might as well do it near the end as we
-        * save the stat call if we exit early.
-        */
+       // Make sure we have a CACHEDIR.TAG in the cache part of cache_dir. This can
+       // be done almost anywhere, but we might as well do it near the end as we
+       // save the stat call if we exit early.
        {
                char *first_level_dir = dirname(stats_file);
                if (create_cachedirtag(first_level_dir) != 0) {
@@ -1372,8 +1318,8 @@ to_cache(struct args *args)
                }
                free(first_level_dir);
 
-               /* Remove any CACHEDIR.TAG on the cache_dir level where it was located in
-                * previous ccache versions. */
+               // Remove any CACHEDIR.TAG on the cache_dir level where it was located in
+               // previous ccache versions.
                if (getpid() % 1000 == 0) {
                        char *path = format("%s/CACHEDIR.TAG", conf->cache_dir);
                        x_unlink(path);
@@ -1381,7 +1327,7 @@ to_cache(struct args *args)
                }
        }
 
-       /* Everything OK. */
+       // Everything OK.
        send_cached_stderr();
        update_manifest_file();
 
@@ -1391,10 +1337,8 @@ to_cache(struct args *args)
        free(tmp_dwo);
 }
 
-/*
- * Find the object file name by running the compiler in preprocessor mode.
- * Returns the hash as a heap-allocated hex string.
- */
+// Find the object file name by running the compiler in preprocessor mode.
+// Returns the hash as a heap-allocated hex string.
 static struct file_hash *
 get_object_name_from_cpp(struct args *args, struct mdfour *hash)
 {
@@ -1404,10 +1348,8 @@ get_object_name_from_cpp(struct args *args, struct mdfour *hash)
        int status, path_stderr_fd;
        struct file_hash *result;
 
-       /* ~/hello.c -> tmp.hello.123.i
-        * limit the basename to 10
-        * characters in order to cope with filesystem with small
-        * maximum filename length limits */
+       // Limit the basename to 10 characters in order to cope with filesystem with
+       // small maximum filename length limits.
        input_base = basename(input_file);
        tmp = strchr(input_base, '.');
        if (tmp) {
@@ -1424,12 +1366,12 @@ get_object_name_from_cpp(struct args *args, struct mdfour *hash)
        time_of_compilation = time(NULL);
 
        if (direct_i_file) {
-               /* We are compiling a .i or .ii file - that means we can skip the cpp stage
-                * and directly form the correct i_tmpfile. */
+               // We are compiling a .i or .ii file - that means we can skip the cpp stage
+               // and directly form the correct i_tmpfile.
                path_stdout = input_file;
                status = 0;
        } else {
-               /* Run cpp on the input file to obtain the .i. */
+               // Run cpp on the input file to obtain the .i.
                int path_stdout_fd;
                path_stdout = format("%s/%s.stdout", temp_dir(), input_base);
                path_stdout_fd = create_tmp_fd(&path_stdout);
@@ -1455,8 +1397,8 @@ get_object_name_from_cpp(struct args *args, struct mdfour *hash)
        }
 
        if (conf->unify) {
-               /* When we are doing the unifying tricks we need to include the input file
-                * name in the hash to get the warnings right. */
+               // When we are doing the unifying tricks we need to include the input file
+               // name in the hash to get the warnings right.
                hash_delimiter(hash, "unifyfilename");
                hash_string(hash, input_file);
 
@@ -1482,8 +1424,8 @@ get_object_name_from_cpp(struct args *args, struct mdfour *hash)
        if (direct_i_file) {
                i_tmpfile = input_file;
        } else {
-               /* i_tmpfile needs the proper cpp_extension for the compiler to do its
-                * thing correctly. */
+               // i_tmpfile needs the proper cpp_extension for the compiler to do its
+               // thing correctly
                i_tmpfile = format("%s.%s", path_stdout, conf->cpp_extension);
                x_rename(path_stdout, i_tmpfile);
                add_pending_tmp_file(i_tmpfile);
@@ -1492,11 +1434,8 @@ get_object_name_from_cpp(struct args *args, struct mdfour *hash)
        if (conf->run_second_cpp) {
                free(path_stderr);
        } else {
-               /*
-                * If we are using the CPP trick, we need to remember this
-                * stderr data and output it just before the main stderr from
-                * the compiler pass.
-                */
+               // If we are using the CPP trick, we need to remember this stderr data and
+               // output it just before the main stderr from the compiler pass.
                cpp_stderr = path_stderr;
                hash_delimiter(hash, "runsecondcpp");
                hash_string(hash, "false");
@@ -1530,16 +1469,14 @@ update_cached_result_globals(struct file_hash *hash)
        free(object_name);
 }
 
-/*
- * Hash mtime or content of a file, or the output of a command, according to
- * the CCACHE_COMPILERCHECK setting.
- */
+// Hash mtime or content of a file, or the output of a command, according to
+// the CCACHE_COMPILERCHECK setting.
 static void
 hash_compiler(struct mdfour *hash, struct stat *st, const char *path,
               bool allow_command)
 {
        if (str_eq(conf->compiler_check, "none")) {
-               /* Do nothing. */
+               // Do nothing.
        } else if (str_eq(conf->compiler_check, "mtime")) {
                hash_delimiter(hash, "cc_mtime");
                hash_int(hash, st->st_size);
@@ -1550,7 +1487,7 @@ hash_compiler(struct mdfour *hash, struct stat *st, const char *path,
        } else if (str_eq(conf->compiler_check, "content") || !allow_command) {
                hash_delimiter(hash, "cc_content");
                hash_file(hash, path);
-       } else { /* command string */
+       } else { // command string
                if (!hash_multicommand_output(
                      hash, conf->compiler_check, orig_args->argv[0])) {
                        fatal("Failure running compiler check command: %s", conf->compiler_check);
@@ -1558,10 +1495,8 @@ hash_compiler(struct mdfour *hash, struct stat *st, const char *path,
        }
 }
 
-/*
- * Note that these compiler checks are unreliable, so nothing should
- * hard-depend on them.
- */
+// Note that these compiler checks are unreliable, so nothing should
+// hard-depend on them.
 
 static bool
 compiler_is_clang(struct args *args)
@@ -1581,10 +1516,8 @@ compiler_is_gcc(struct args *args)
        return is;
 }
 
-/*
- * Update a hash sum with information common for the direct and preprocessor
- * modes.
- */
+// Update a hash sum with information common for the direct and preprocessor
+// modes.
 static void
 calculate_common_hash(struct args *args, struct mdfour *hash)
 {
@@ -1598,10 +1531,8 @@ calculate_common_hash(struct args *args, struct mdfour *hash)
 
        hash_string(hash, HASH_PREFIX);
 
-       /*
-        * We have to hash the extension, as a .i file isn't treated the same
-        * by the compiler as a .ii file.
-        */
+       // We have to hash the extension, as a .i file isn't treated the same by the
+       // compiler as a .ii file.
        hash_delimiter(hash, "ext");
        hash_string(hash, conf->cpp_extension);
 
@@ -1619,21 +1550,17 @@ calculate_common_hash(struct args *args, struct mdfour *hash)
                failed();
        }
 
-       /*
-        * Hash information about the compiler.
-        */
+       // Hash information about the compiler.
        hash_compiler(hash, &st, args->argv[0], true);
 
-       /*
-        * Also hash the compiler name as some compilers use hard links and
-        * behave differently depending on the real name.
-        */
+       // Also hash the compiler name as some compilers use hard links and behave
+       // differently depending on the real name.
        hash_delimiter(hash, "cc_name");
        p = basename(args->argv[0]);
        hash_string(hash, p);
        free(p);
 
-       /* Possibly hash the current working directory. */
+       // Possibly hash the current working directory.
        if (generating_debuginfo && conf->hash_dir) {
                char *cwd = gnu_getcwd();
                if (debug_prefix_map) {
@@ -1660,7 +1587,7 @@ calculate_common_hash(struct args *args, struct mdfour *hash)
                }
        }
 
-       /* Possibly hash the coverage data file path. */
+       // Possibly hash the coverage data file path.
        if (generating_coverage && profile_arcs) {
                char *dir = dirname(output_obj);
                if (profile_dir) {
@@ -1700,7 +1627,7 @@ calculate_common_hash(struct args *args, struct mdfour *hash)
                free(p);
        }
 
-       /* Possibly hash GCC_COLORS (for color diagnostics). */
+       // Possibly hash GCC_COLORS (for color diagnostics).
        if (compiler_is_gcc(args)) {
                const char *gcc_colors = getenv("GCC_COLORS");
                if (gcc_colors) {
@@ -1710,11 +1637,9 @@ calculate_common_hash(struct args *args, struct mdfour *hash)
        }
 }
 
-/*
- * Update a hash sum with information specific to the direct and preprocessor
- * modes and calculate the object hash. Returns the object hash on success,
- * otherwise NULL. Caller frees.
- */
+// Update a hash sum with information specific to the direct and preprocessor
+// modes and calculate the object hash. Returns the object hash on success,
+// otherwise NULL. Caller frees.
 static struct file_hash *
 calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
 {
@@ -1728,9 +1653,9 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                hash_int(hash, MANIFEST_VERSION);
        }
 
-       /* first the arguments */
+       // First the arguments.
        for (i = 1; i < args->argc; i++) {
-               /* -L doesn't affect compilation. */
+               // -L doesn't affect compilation.
                if (i < args->argc-1 && str_eq(args->argv[i], "-L")) {
                        i++;
                        continue;
@@ -1739,22 +1664,22 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                        continue;
                }
 
-               /* -Wl,... doesn't affect compilation. */
+               // -Wl,... doesn't affect compilation.
                if (str_startswith(args->argv[i], "-Wl,")) {
                        continue;
                }
 
-               /* The -fdebug-prefix-map option may be used in combination with
-                * CCACHE_BASEDIR to reuse results across different directories. Skip it
-                * from hashing. */
+               // The -fdebug-prefix-map option may be used in combination with
+               // CCACHE_BASEDIR to reuse results across different directories. Skip it
+               // from hashing.
                if (str_startswith(args->argv[i], "-fdebug-prefix-map=")) {
                        continue;
                }
 
-               /* When using the preprocessor, some arguments don't contribute
-                * to the hash. The theory is that these arguments will change
-                * the output of -E if they are going to have any effect at
-                * all. For precompiled headers this might not be the case. */
+               // When using the preprocessor, some arguments don't contribute to the
+               // hash. The theory is that these arguments will change the output of -E if
+               // they are going to have any effect at all. For precompiled headers this
+               // might not be the case.
                if (!direct_mode && !output_is_precompiled_header
                    && !using_precompiled_header) {
                        if (compopt_affects_cpp(args->argv[i])) {
@@ -1766,10 +1691,8 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                        }
                }
 
-               /* If we're generating dependencies, we make sure to skip the
-                * filename of the dependency file, since it doesn't impact the
-                * output.
-                */
+               // If we're generating dependencies, we make sure to skip the filename of
+               // the dependency file, since it doesn't impact the output.
                if (generating_dependencies) {
                        if (str_startswith(args->argv[i], "-Wp,")) {
                                if (str_startswith(args->argv[i], "-Wp,-MD,")
@@ -1784,12 +1707,11 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                        } else if (str_startswith(args->argv[i], "-MF")) {
                                bool separate_argument = (strlen(args->argv[i]) == 3);
 
-                               /* In either case, hash the "-MF" part. */
+                               // In either case, hash the "-MF" part.
                                hash_string_length(hash, args->argv[i], 3);
 
                                if (separate_argument) {
-                                       /* Next argument is dependency name, so
-                                        * skip it. */
+                                       // Next argument is dependency name, so skip it.
                                        i++;
                                }
                                continue;
@@ -1803,8 +1725,8 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                        p = args->argv[i] + 8;
                }
                if (p && x_stat(p, &st) == 0) {
-                       /* If given an explicit specs file, then hash that file,
-                        * but don't include the path to it in the hash. */
+                       // If given an explicit specs file, then hash that file, but don't
+                       // include the path to it in the hash.
                        hash_delimiter(hash, "specs");
                        hash_compiler(hash, &st, p, false);
                        continue;
@@ -1828,7 +1750,7 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                        continue;
                }
 
-               /* All other arguments are included in the hash. */
+               // All other arguments are included in the hash.
                hash_delimiter(hash, "arg");
                hash_string(hash, args->argv[i]);
                if (i + 1 < args->argc && compopt_takes_arg(args->argv[i])) {
@@ -1838,25 +1760,21 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                }
        }
 
-       /*
-        * For profile generation (-fprofile-arcs, -fprofile-generate):
-        * - hash profile directory
-        * - output to the real file first
-        *
-        * For profile usage (-fprofile-use):
-        * - hash profile data
-        *
-        * -fbranch-probabilities and -fvpt usage is covered by
-        * -fprofile-generate/-fprofile-use.
-        *
-        * The profile directory can be specified as an argument to
-        * -fprofile-generate=, -fprofile-use=, or -fprofile-dir=.
-        */
-
-       /*
-        * We need to output to the real object first here, otherwise runtime
-        * artifacts will be produced in the wrong place.
-        */
+       // For profile generation (-fprofile-arcs, -fprofile-generate):
+       // - hash profile directory
+       // - output to the real file first
+       //
+       // For profile usage (-fprofile-use):
+       // - hash profile data
+       //
+       // -fbranch-probabilities and -fvpt usage is covered by
+       // -fprofile-generate/-fprofile-use.
+       //
+       // The profile directory can be specified as an argument to
+       // -fprofile-generate=, -fprofile-use=, or -fprofile-dir=.
+
+       // We need to output to the real object first here, otherwise runtime
+       // artifacts will be produced in the wrong place.
        if (profile_generate) {
                if (!profile_dir) {
                        profile_dir = get_cwd();
@@ -1867,7 +1785,7 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
        }
 
        if (profile_use) {
-               /* Calculate gcda name */
+               // Calculate gcda name.
                char *gcda_name;
                char *base_name;
                base_name = remove_extension(output_obj);
@@ -1876,7 +1794,7 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                }
                gcda_name = format("%s/%s.gcda", profile_dir, base_name);
                cc_log("Adding profile data %s to our hash", gcda_name);
-               /* Add the gcda to our hash */
+               // Add the gcda to our hash.
                hash_delimiter(hash, "-fprofile-use");
                hash_file(hash, gcda_name);
                free(base_name);
@@ -1887,14 +1805,14 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                char *manifest_name;
                int result;
 
-               /* Hash environment variables that affect the preprocessor output. */
+               // Hash environment variables that affect the preprocessor output.
                const char **p;
                const char *envvars[] = {
                        "CPATH",
                        "C_INCLUDE_PATH",
                        "CPLUS_INCLUDE_PATH",
                        "OBJC_INCLUDE_PATH",
-                       "OBJCPLUS_INCLUDE_PATH", /* clang */
+                       "OBJCPLUS_INCLUDE_PATH", // clang
                        NULL
                };
                for (p = envvars; *p; ++p) {
@@ -1906,11 +1824,8 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                }
 
                if (!(conf->sloppiness & SLOPPY_FILE_MACRO)) {
-                       /*
-                        * The source code file or an include file may contain
-                        * __FILE__, so make sure that the hash is unique for
-                        * the file name.
-                        */
+                       // The source code file or an include file may contain __FILE__, so make
+                       // sure that the hash is unique for the file name.
                        hash_delimiter(hash, "inputfile");
                        hash_string(hash, input_file);
                }
@@ -1962,17 +1877,15 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
        return object_hash;
 }
 
-/*
- * Try to return the compile result from cache. If we can return from cache
- * then this function exits with the correct status code, otherwise it returns.
- */
+// Try to return the compile result from cache. If we can return from cache
+// then this function exits with the correct status code, otherwise it returns.
 static void
 from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest)
 {
        struct stat st;
        bool produce_dep_file = false;
 
-       /* the user might be disabling cache hits */
+       // The user might be disabling cache hits.
        if (conf->recache) {
                return;
        }
@@ -1982,16 +1895,14 @@ from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest)
                return;
        }
 
-       /* Check if the diagnostic file is there. */
+       // Check if the diagnostic file is there.
        if (output_dia && stat(cached_dia, &st) != 0) {
                cc_log("Diagnostic file %s not in cache", cached_dia);
                return;
        }
 
-       /*
-        * Occasionally, e.g. on hard reset, our cache ends up as just filesystem
-        * meta-data with no content. Catch an easy case of this.
-        */
+       // Occasionally, e.g. on hard reset, our cache ends up as just filesystem
+       // meta-data with no content. Catch an easy case of this.
        if (st.st_size == 0) {
                cc_log("Invalid (empty) object file %s in cache", cached_obj);
                x_unlink(cached_obj);
@@ -2010,27 +1921,22 @@ from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest)
                if (st.st_size == 0) {
                        cc_log("Invalid (empty) dwo file %s in cache", cached_dwo);
                        x_unlink(cached_dwo);
-                       x_unlink(cached_obj); /* to really invalidate */
+                       x_unlink(cached_obj); // To really invalidate.
                        return;
                }
        }
 
-       /*
-        * (If mode != FROMCACHE_DIRECT_MODE, the dependency file is created by
-        * gcc.)
-        */
+       // (If mode != FROMCACHE_DIRECT_MODE, the dependency file is created by gcc.)
        produce_dep_file = generating_dependencies && mode == FROMCACHE_DIRECT_MODE;
 
-       /* If the dependency file should be in the cache, check that it is. */
+       // If the dependency file should be in the cache, check that it is.
        if (produce_dep_file && stat(cached_dep, &st) != 0) {
                cc_log("Dependency file %s missing in cache", cached_dep);
                return;
        }
 
-       /*
-        * Copy object file from cache. Do so also for FissionDwarf file, cached_dwo,
-        * when -gsplit-dwarf is specified.
-        */
+       // Copy object file from cache. Do so also for FissionDwarf file, cached_dwo,
+       // when -gsplit-dwarf is specified.
        if (!str_eq(output_obj, "/dev/null")) {
                get_file_from_cache(cached_obj, output_obj);
                if (using_split_dwarf) {
@@ -2042,15 +1948,15 @@ from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest)
                get_file_from_cache(cached_dep, output_dep);
        }
        if (generating_coverage && stat(cached_cov, &st) == 0 && st.st_size > 0) {
-               /* gcc won't generate notes if there is no code */
+               // The compiler won't generate notes if there is no code
                get_file_from_cache(cached_cov, output_cov);
        }
        if (output_dia) {
                get_file_from_cache(cached_dia, output_dia);
        }
 
-       /* Update modification timestamps to save files from LRU cleanup.
-        * Also gives files a sensible mtime when hard-linking. */
+       // Update modification timestamps to save files from LRU cleanup. Also gives
+       // files a sensible mtime when hard-linking.
        update_mtime(cached_obj);
        update_mtime(cached_stderr);
        if (produce_dep_file) {
@@ -2077,7 +1983,7 @@ from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest)
                update_manifest_file();
        }
 
-       /* log the cache hit */
+       // Log the cache hit.
        switch (mode) {
        case FROMCACHE_DIRECT_MODE:
                cc_log("Succeeded getting cached result");
@@ -2090,12 +1996,12 @@ from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest)
                break;
        }
 
-       /* and exit with the right status code */
+       // And exit with the right status code.
        x_exit(0);
 }
 
-/* find the real compiler. We just search the PATH to find an executable of the
- * same name that isn't a link to ourselves */
+// Find the real compiler. We just search the PATH to find an executable of the
+// same name that isn't a link to ourselves.
 static void
 find_compiler(char **argv)
 {
@@ -2104,25 +2010,25 @@ find_compiler(char **argv)
 
        base = basename(argv[0]);
 
-       /* we might be being invoked like "ccache gcc -c foo.c" */
+       // We might be being invoked like "ccache gcc -c foo.c".
        if (same_executable_name(base, MYNAME)) {
                args_remove_first(orig_args);
                free(base);
                if (is_full_path(orig_args->argv[0])) {
-                       /* a full path was given */
+                       // A full path was given.
                        return;
                }
                base = basename(orig_args->argv[0]);
        }
 
-       /* support user override of the compiler */
+       // Support user override of the compiler.
        if (!str_eq(conf->compiler, "")) {
                base = conf->compiler;
        }
 
        compiler = find_executable(base, MYNAME);
 
-       /* can't find the compiler! */
+       // Can't find the compiler!
        if (!compiler) {
                stats_update(STATS_COMPILER);
                fatal("Could not find compiler \"%s\" in PATH", base);
@@ -2155,7 +2061,7 @@ detect_pch(const char *option, const char *arg, bool *found_pch)
        char *pch_file = NULL;
        struct stat st;
 
-       /* Try to be smart about detecting precompiled headers */
+       // Try to be smart about detecting precompiled headers.
        if (str_eq(option, "-include-pch") || str_eq(option, "-include-pth")) {
                if (stat(arg, &st) == 0) {
                        cc_log("Detected use of precompiled header: %s", arg);
@@ -2172,7 +2078,7 @@ detect_pch(const char *option, const char *arg, bool *found_pch)
                                cc_log("Detected use of precompiled header: %s", pchpath);
                                pch_file = x_strdup(pchpath);
                        } else {
-                               /* clang may use pretokenized headers */
+                               // clang may use pretokenized headers.
                                char *pthpath = format("%s.pth", arg);
                                if (stat(pthpath, &st) == 0) {
                                        cc_log("Detected use of pretokenized header: %s", pthpath);
@@ -2198,11 +2104,9 @@ detect_pch(const char *option, const char *arg, bool *found_pch)
        return true;
 }
 
-/*
- * Process the compiler options into options suitable for passing to the
- * preprocessor and the real compiler. The preprocessor options don't include
- * -E; this is added later. Returns true on success, otherwise false.
- */
+// Process the compiler options into options suitable for passing to the
+// preprocessor and the real compiler. The preprocessor options don't include
+// -E; this is added later. Returns true on success, otherwise false.
 bool
 cc_process_args(struct args *args, struct args **preprocessor_args,
                 struct args **compiler_args)
@@ -2213,30 +2117,30 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
        bool found_S_opt = false;
        bool found_pch = false;
        bool found_fpch_preprocess = false;
-       const char *explicit_language = NULL; /* As specified with -x. */
-       const char *file_language;            /* As deduced from file extension. */
-       const char *actual_language;          /* Language to actually use. */
+       const char *explicit_language = NULL; // As specified with -x.
+       const char *file_language;            // As deduced from file extension.
+       const char *actual_language;          // Language to actually use.
        const char *input_charset = NULL;
        struct stat st;
-       /* Is the dependency makefile name overridden with -MF? */
+       // Is the dependency makefile name overridden with -MF?
        bool dependency_filename_specified = false;
-       /* Is the dependency makefile target name specified with -MT or -MQ? */
+       // Is the dependency makefile target name specified with -MT or -MQ?
        bool dependency_target_specified = false;
-       /* expanded_args is a copy of the original arguments given to the compiler
-          but with arguments from @file and similar constructs expanded. It's only
-          used as a temporary data structure to loop over. */
+       // expanded_args is a copy of the original arguments given to the compiler
+       // but with arguments from @file and similar constructs expanded. It's only
+       // used as a temporary data structure to loop over.
        struct args *expanded_args;
-       /* stripped_args essentially contains all original arguments except those
-          that only should be passed to the preprocessor (if run_second_cpp is
-          false) and except dependency options (like -MD and friends). */
+       // stripped_args essentially contains all original arguments except those
+       // that only should be passed to the preprocessor (if run_second_cpp is
+       // false) and except dependency options (like -MD and friends).
        struct args *stripped_args;
-       /* cpp_args contains arguments that were not added to stripped_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. */
+       // cpp_args contains arguments that were not added to stripped_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;
-       /* dep_args contains dependency options like -MD. They only passed to the
-          preprocessor, never to the compiler. */
+       // dep_args contains dependency options like -MD. They only passed to the
+       // preprocessor, never to the compiler.
        struct args *dep_args;
        int argc;
        char **argv;
@@ -2256,7 +2160,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
        args_add(stripped_args, argv[0]);
 
        for (i = 1; i < argc; i++) {
-               /* The user knows best: just swallow the next arg */
+               // The user knows best: just swallow the next arg.
                if (str_eq(argv[i], "--ccache-skip")) {
                        i++;
                        if (i == argc) {
@@ -2268,14 +2172,14 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /* Special case for -E. */
+               // Special case for -E.
                if (str_eq(argv[i], "-E")) {
                        stats_update(STATS_PREPROCESSING);
                        result = false;
                        goto out;
                }
 
-               /* Handle "@file" argument. */
+               // Handle "@file" argument.
                if (str_startswith(argv[i], "@") || str_startswith(argv[i], "-@")) {
                        char *argpath = argv[i] + 1;
                        struct args *file_args;
@@ -2298,7 +2202,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /* Handle cuda "-optf" and "--options-file" argument. */
+               // Handle cuda "-optf" and "--options-file" argument.
                if (str_eq(argv[i], "-optf") || str_eq(argv[i], "--options-file")) {
                        if (i > argc) {
                                cc_log("Expected argument after -optf/--options-file");
@@ -2308,7 +2212,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        }
                        ++i;
 
-                       /* Argument is a comma-separated list of files. */
+                       // Argument is a comma-separated list of files.
                        char *str_start = argv[i];
                        char *str_end = strchr(str_start, ',');
                        int index = i + 1;
@@ -2339,7 +2243,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /* These are always too hard. */
+               // These are always too hard.
                if (compopt_too_hard(argv[i])
                    || str_startswith(argv[i], "-fdump-")) {
                        cc_log("Compiler option %s is unsupported", argv[i]);
@@ -2348,7 +2252,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        goto out;
                }
 
-               /* These are too hard in direct mode. */
+               // These are too hard in direct mode.
                if (conf->direct_mode) {
                        if (compopt_too_hard_for_direct_mode(argv[i])) {
                                cc_log("Unsupported compiler option for direct mode: %s", argv[i]);
@@ -2356,7 +2260,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        }
                }
 
-               /* -Xarch_* options are too hard. */
+               // -Xarch_* options are too hard.
                if (str_startswith(argv[i], "-Xarch_")) {
                        cc_log("Unsupported compiler option :%s", argv[i]);
                        stats_update(STATS_UNSUPPORTED);
@@ -2364,7 +2268,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        goto out;
                }
 
-               /* Handle -arch options. */
+               // Handle -arch options.
                if (str_eq(argv[i], "-arch")) {
                        if (arch_args_size == MAX_ARCH_ARGS - 1) {
                                cc_log("Too many -arch compiler options; ccache supports at most %d",
@@ -2375,7 +2279,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        }
 
                        ++i;
-                       arch_args[arch_args_size] = x_strdup(argv[i]); /* it will leak */
+                       arch_args[arch_args_size] = x_strdup(argv[i]); // It will leak.
                        ++arch_args_size;
                        if (arch_args_size == 2) {
                                conf->run_second_cpp = true;
@@ -2389,23 +2293,21 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        found_fpch_preprocess = true;
                }
 
-               /* we must have -c */
+               // We must have -c.
                if (str_eq(argv[i], "-c")) {
                        found_c_opt = true;
                        continue;
                }
 
-               /* -S changes the default extension */
+               // -S changes the default extension.
                if (str_eq(argv[i], "-S")) {
                        args_add(stripped_args, argv[i]);
                        found_S_opt = true;
                        continue;
                }
 
-               /*
-                * Special handling for -x: remember the last specified language before the
-                * input file and strip all -x options from the arguments.
-                */
+               // Special handling for -x: remember the last specified language before the
+               // input file and strip all -x options from the arguments.
                if (str_eq(argv[i], "-x")) {
                        if (i == argc-1) {
                                cc_log("Missing argument to %s", argv[i]);
@@ -2426,7 +2328,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /* we need to work out where the output was meant to go */
+               // We need to work out where the output was meant to go.
                if (str_eq(argv[i], "-o")) {
                        if (i == argc-1) {
                                cc_log("Missing argument to %s", argv[i]);
@@ -2439,7 +2341,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /* alternate form of -o, with no space */
+               // Alternate form of -o with no space.
                if (str_startswith(argv[i], "-o")) {
                        output_obj = make_relative_path(x_strdup(&argv[i][2]));
                        continue;
@@ -2457,8 +2359,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /* Debugging is handled specially, so that we know if we can strip line
-                * number info. */
+               // Debugging is handled specially, so that we know if we can strip line
+               // number info.
                if (str_startswith(argv[i], "-g")) {
                        const char *pLevel = argv[i] + 2;
                        int foundlevel = -1;
@@ -2474,7 +2376,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                pLevel = argv[i] + 5;
                        }
 
-                       /* Deduce level from argument, default is 2. */
+                       // Deduce level from argument, default is 2.
                        if (pLevel[0] == '\0') {
                                foundlevel = 2;
                        } else if (pLevel[0] >= '0' && pLevel[0] <= '9') {
@@ -2488,9 +2390,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        }
                }
 
-               /* These options require special handling, because they
-                * behave differently with gcc -E, when the output
-                * file is not specified. */
+               // These options require special handling, because they behave differently
+               // with gcc -E, when the output file is not specified.
                if (str_eq(argv[i], "-MD") || str_eq(argv[i], "-MMD")) {
                        generating_dependencies = true;
                        args_add(dep_args, argv[i]);
@@ -2502,7 +2403,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        dependency_filename_specified = true;
                        free(output_dep);
                        if (separate_argument) {
-                               /* -MF arg */
+                               // -MF arg
                                if (i >= argc - 1) {
                                        cc_log("Missing argument to %s", argv[i]);
                                        stats_update(STATS_ARGS);
@@ -2512,11 +2413,11 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                arg = argv[i + 1];
                                i++;
                        } else {
-                               /* -MFarg */
+                               // -MFarg
                                arg = &argv[i][3];
                        }
                        output_dep = make_relative_path(x_strdup(arg));
-                       /* Keep the format of the args the same */
+                       // Keep the format of the args the same.
                        if (separate_argument) {
                                args_add(dep_args, "-MF");
                                args_add(dep_args, output_dep);
@@ -2531,7 +2432,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        char *relpath;
                        dependency_target_specified = true;
                        if (strlen(argv[i]) == 3) {
-                               /* -MQ arg or -MT arg */
+                               // -MQ arg or -MT arg
                                if (i >= argc - 1) {
                                        cc_log("Missing argument to %s", argv[i]);
                                        stats_update(STATS_ARGS);
@@ -2566,7 +2467,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        args_add(stripped_args, argv[i]);
                        continue;
                }
-               if (str_eq(argv[i], "--coverage")) { /* = -fprofile-arcs -ftest-coverage */
+               if (str_eq(argv[i], "--coverage")) { // = -fprofile-arcs -ftest-coverage
                        profile_arcs = true;
                        generating_coverage = true;
                        args_add(stripped_args, argv[i]);
@@ -2587,9 +2488,9 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                }
                if (str_startswith(argv[i], "-Wp,")) {
                        if (str_eq(argv[i], "-Wp,-P") || strstr(argv[i], ",-P,")) {
-                               /* -P removes preprocessor information in such a way that the object
-                                * file from compiling the preprocessed file will not be equal to the
-                                * object file produced when compiling without ccache. */
+                               // -P removes preprocessor information in such a way that the object
+                               // file from compiling the preprocessed file will not be equal to the
+                               // object file produced when compiling without ccache.
                                cc_log("Too hard option -Wp,-P detected");
                                stats_update(STATS_UNSUPPORTED);
                                failed();
@@ -2611,15 +2512,12 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                continue;
                        } else if (str_startswith(argv[i], "-Wp,-D")
                                   && !strchr(argv[i] + 6, ',')) {
-                               /* Treat it like -D */
+                               // Treat it like -D.
                                args_add(dep_args, argv[i] + 4);
                                continue;
                        } else if (conf->direct_mode) {
-                               /*
-                                * -Wp, can be used to pass too hard options to
-                                * the preprocessor. Hence, disable direct
-                                * mode.
-                                */
+                               // -Wp, can be used to pass too hard options to the preprocessor.
+                               // Hence, disable direct mode.
                                cc_log("Unsupported compiler option for direct mode: %s", argv[i]);
                                conf->direct_mode = false;
                        }
@@ -2629,7 +2527,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /* Input charset needs to be handled specially. */
+               // Input charset needs to be handled specially.
                if (str_startswith(argv[i], "-finput-charset=")) {
                        input_charset = argv[i];
                        continue;
@@ -2656,14 +2554,14 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                char *option = x_strndup(argv[i], arg_profile_dir - argv[i]);
                                char *dir;
 
-                               /* Convert to absolute path. */
+                               // Convert to absolute path.
                                dir = x_realpath(arg_profile_dir + 1);
                                if (!dir) {
-                                       /* Directory doesn't exist. */
+                                       // Directory doesn't exist.
                                        dir = x_strdup(arg_profile_dir + 1);
                                }
 
-                               /* We can get a better hit rate by using the real path here. */
+                               // We can get a better hit rate by using the real path here.
                                free(arg);
                                arg = format("%s=%s", option, dir);
                                cc_log("Rewriting %s to %s", argv[i], arg);
@@ -2687,10 +2585,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                args_add(stripped_args, arg);
                                free(arg);
 
-                               /*
-                                * If the profile directory has already been set, give up... Hard to
-                                * know what the user means, and what the compiler will do.
-                                */
+                               // If the profile directory has already been set, give up... Hard to
+                               // know what the user means, and what the compiler will do.
                                if (arg_profile_dir && profile_dir) {
                                        cc_log("Profile directory already set; giving up");
                                        result = false;
@@ -2717,7 +2613,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                }
                if (str_eq(argv[i], "-fdiagnostics-color=auto")) {
                        if (color_output_possible()) {
-                               /* Output is redirected, so color output must be forced. */
+                               // Output is redirected, so color output must be forced.
                                args_add(stripped_args, "-fdiagnostics-color=always");
                                cc_log("Automatically forcing colors");
                        } else {
@@ -2727,11 +2623,9 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /*
-                * Options taking an argument that we may want to rewrite to relative paths
-                * to get better hit rate. A secondary effect is that paths in the standard
-                * error output produced by the compiler will be normalized.
-                */
+               // Options taking an argument that we may want to rewrite to relative paths
+               // to get better hit rate. A secondary effect is that paths in the standard
+               // error output produced by the compiler will be normalized.
                if (compopt_takes_path(argv[i])) {
                        char *relpath;
                        if (i == argc-1) {
@@ -2760,10 +2654,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /*
-                * Same as above but options with concatenated argument beginning with a
-                * slash.
-                */
+               // Same as above but options with concatenated argument beginning with a
+               // slash.
                if (argv[i][0] == '-') {
                        char *slash_pos = strchr(argv[i], '/');
                        if (slash_pos) {
@@ -2786,7 +2678,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        }
                }
 
-               /* options that take an argument */
+               // Options that take an argument.
                if (compopt_takes_arg(argv[i])) {
                        if (i == argc-1) {
                                cc_log("Missing argument to %s", argv[i]);
@@ -2807,7 +2699,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /* other options */
+               // Other options.
                if (argv[i][0] == '-') {
                        if (compopt_affects_cpp(argv[i])
                            || compopt_prefix_affects_cpp(argv[i])) {
@@ -2818,9 +2710,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        continue;
                }
 
-               /* if an argument isn't a plain file then assume its
-                * an option, not an input file. This allows us to
-                * cope better with unusual compiler options */
+               // If an argument isn't a plain file then assume its an option, not an
+               // input file. This allows us to cope better with unusual compiler options.
                if (stat(argv[i], &st) != 0 || !S_ISREG(st.st_mode)) {
                        cc_log("%s is not a regular file, not considering as input file",
                               argv[i]);
@@ -2847,23 +2738,23 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        goto out;
                }
 
-               /* The source code file path gets put into the notes */
+               // The source code file path gets put into the notes.
                if (generating_coverage) {
                        input_file = x_strdup(argv[i]);
                        continue;
                }
 
                if (is_symlink(argv[i])) {
-                       /* Don't rewrite source file path if it's a symlink since
-                          make_relative_path resolves symlinks using realpath(3) and this leads
-                          to potentially choosing incorrect relative header files. See the
-                          "symlink to source file" test. */
+                       // Don't rewrite source file path if it's a symlink since
+                       // make_relative_path resolves symlinks using realpath(3) and this leads
+                       // to potentially choosing incorrect relative header files. See the
+                       // "symlink to source file" test.
                        input_file = x_strdup(argv[i]);
                } else {
-                       /* Rewrite to relative to increase hit rate. */
+                       // Rewrite to relative to increase hit rate.
                        input_file = make_relative_path(x_strdup(argv[i]));
                }
-       } /* for */
+       } // for
 
        if (debug_level > 0) {
                generating_debuginfo = true;
@@ -2879,9 +2770,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
        }
 
        if (found_S_opt) {
-               /* Even if -gsplit-dwarf is given, the .dwo file is not generated when -S
-                * is also given.
-                */
+               // Even if -gsplit-dwarf is given, the .dwo file is not generated when -S
+               // is also given.
                using_split_dwarf = false;
                cc_log("Disabling caching of dwarf files since -S is used");
        }
@@ -2938,8 +2828,8 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        args_add(stripped_args, "-c");
                } else {
                        cc_log("No -c option found");
-                       /* I find that having a separate statistic for autoconf tests is useful,
-                        * as they are the dominant form of "called for link" in many cases */
+                       // I find that having a separate statistic for autoconf tests is useful,
+                       // as they are the dominant form of "called for link" in many cases.
                        if (strstr(input_file, "conftest.")) {
                                stats_update(STATS_CONFTEST);
                        } else {
@@ -2960,7 +2850,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
        direct_i_file = language_is_preprocessed(actual_language);
 
        if (output_is_precompiled_header) {
-               /* It doesn't work to create the .gch from preprocessed source. */
+               // It doesn't work to create the .gch from preprocessed source.
                cc_log("Creating precompiled header; not compiling preprocessed code");
                conf->run_second_cpp = true;
        }
@@ -2971,7 +2861,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                conf->cpp_extension = x_strdup(extension_for_language(p_language) + 1);
        }
 
-       /* don't try to second guess the compilers heuristics for stdout handling */
+       // Don't try to second guess the compilers heuristics for stdout handling.
        if (output_obj && str_eq(output_obj, "-")) {
                stats_update(STATS_OUTSTDOUT);
                cc_log("Output file is -");
@@ -3013,7 +2903,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                }
        }
 
-       /* cope with -o /dev/null */
+       // Cope with -o /dev/null.
        if (!str_eq(output_obj, "/dev/null")
            && stat(output_obj, &st) == 0
            && !S_ISREG(st.st_mode)) {
@@ -3023,13 +2913,11 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                goto out;
        }
 
-       /*
-        * Some options shouldn't be passed to the real compiler when it compiles
-        * preprocessed code:
-        *
-        * -finput-charset=XXX (otherwise conversion happens twice)
-        * -x XXX (otherwise the wrong language is selected)
-        */
+       // Some options shouldn't be passed to the real compiler when it compiles
+       // preprocessed code:
+       //
+       // -finput-charset=XXX (otherwise conversion happens twice)
+       // -x XXX (otherwise the wrong language is selected)
        if (input_charset) {
                args_add(cpp_args, input_charset);
        }
@@ -3041,21 +2929,17 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                args_add(cpp_args, explicit_language);
        }
 
-       /*
-        * Since output is redirected, compilers will not color their output by
-        * default, so force it explicitly if it would be otherwise done.
-        */
+       // Since output is redirected, compilers will not color their output by
+       // default, so force it explicitly if it would be otherwise done.
        if (!found_color_diagnostics && color_output_possible()) {
                if (compiler_is_clang(args)) {
                        args_add(stripped_args, "-fcolor-diagnostics");
                        cc_log("Automatically enabling colors");
                } else if (compiler_is_gcc(args)) {
-                       /*
-                        * GCC has it since 4.9, but that'd require detecting what GCC version is
-                        * used for the actual compile. However it requires also GCC_COLORS to be
-                        * set (and not empty), so use that for detecting if GCC would use
-                        * colors.
-                        */
+                       // GCC has it since 4.9, but that'd require detecting what GCC version is
+                       // used for the actual compile. However it requires also GCC_COLORS to be
+                       // set (and not empty), so use that for detecting if GCC would use
+                       // colors.
                        if (getenv("GCC_COLORS") && getenv("GCC_COLORS")[0] != '\0') {
                                args_add(stripped_args, "-fdiagnostics-color");
                                cc_log("Automatically enabling colors");
@@ -3063,9 +2947,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                }
        }
 
-       /*
-        * Add flags for dependency generation only to the preprocessor command line.
-        */
+       // Add flags for dependency generation only to the preprocessor command line.
        if (generating_dependencies) {
                if (!dependency_filename_specified) {
                        char *default_depfile_name;
@@ -3099,11 +2981,9 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                args_extend(*compiler_args, cpp_args);
        } else {
                if (explicit_language) {
-                       /*
-                        * Workaround for a bug in Apple's patched distcc -- it doesn't properly
-                        * reset the language specified with -x, so if -x is given, we have to
-                        * specify the preprocessed language explicitly.
-                        */
+                       // Workaround for a bug in Apple's patched distcc -- it doesn't properly
+                       // reset the language specified with -x, so if -x is given, we have to
+                       // specify the preprocessed language explicitly.
                        args_add(*compiler_args, "-x");
                        args_add(*compiler_args, p_language_for_language(explicit_language));
                }
@@ -3118,11 +2998,9 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                args_add(*compiler_args, arch_args[j]);
        }
 
-       /*
-        * Only pass dependency arguments to the preprocesor since Intel's C++
-        * compiler doesn't produce a correct .d file when compiling preprocessed
-        * source.
-        */
+       // Only pass dependency arguments to the preprocesor since Intel's C++
+       // compiler doesn't produce a correct .d file when compiling preprocessed
+       // source.
        args_extend(cpp_args, dep_args);
 
        *preprocessor_args = args_copy(stripped_args);
@@ -3152,7 +3030,7 @@ create_initial_config_file(struct conf *conf, const char *path)
        stats_dir = format("%s/0", conf->cache_dir);
        if (stat(stats_dir, &st) == 0) {
                stats_get_obsolete_limits(stats_dir, &max_files, &max_size);
-               /* STATS_MAXFILES and STATS_MAXSIZE was stored for each top directory. */
+               // STATS_MAXFILES and STATS_MAXSIZE was stored for each top directory.
                max_files *= 16;
                max_size *= 16;
        } else {
@@ -3178,10 +3056,8 @@ create_initial_config_file(struct conf *conf, const char *path)
        fclose(f);
 }
 
-/*
- * Read config file(s), populate variables, create configuration file in cache
- * directory if missing, etc.
- */
+// Read config file(s), populate variables, create configuration file in cache
+// directory if missing, etc.
 static void
 initialize(void)
 {
@@ -3202,7 +3078,7 @@ initialize(void)
                        if (stat(secondary_config_path, &st) == 0) {
                                fatal("%s", errmsg);
                        }
-                       /* Missing config file in SYSCONFDIR is OK. */
+                       // Missing config file in SYSCONFDIR is OK.
                        free(errmsg);
                }
 
@@ -3251,7 +3127,7 @@ initialize(void)
        }
 }
 
-/* Reset the global state. Used by the test suite. */
+// Reset the global state. Used by the test suite.
 void
 cc_reset(void)
 {
@@ -3305,8 +3181,8 @@ cc_reset(void)
        using_split_dwarf = false;
 }
 
-/* Make a copy of stderr that will not be cached, so things like
- * distcc can send networking errors to it. */
+// Make a copy of stderr that will not be cached, so things like distcc can
+// send networking errors to it.
 static void
 setup_uncached_err(void)
 {
@@ -3319,7 +3195,7 @@ setup_uncached_err(void)
                failed();
        }
 
-       /* leak a pointer to the environment */
+       // Leak a pointer to the environment.
        buf = format("UNCACHED_ERR_FD=%d", uncached_fd);
 
        if (putenv(buf) == -1) {
@@ -3335,7 +3211,7 @@ configuration_logger(const char *descr, const char *origin, void *context)
        cc_bulklog("Config: (%s) %s", origin, descr);
 }
 
-/* the main ccache driver function */
+// The main ccache driver function.
 static void
 ccache(int argc, char *argv[])
 {
@@ -3346,10 +3222,10 @@ ccache(int argc, char *argv[])
        struct mdfour direct_hash;
        struct mdfour cpp_hash;
 
-       /* Arguments (except -E) to send to the preprocessor. */
+       // Arguments (except -E) to send to the preprocessor.
        struct args *preprocessor_args;
 
-       /* Arguments to send to the real compiler. */
+       // Arguments to send to the real compiler.
        struct args *compiler_args;
 
 #ifndef _WIN32
@@ -3417,7 +3293,7 @@ ccache(int argc, char *argv[])
        hash_start(&common_hash);
        calculate_common_hash(preprocessor_args, &common_hash);
 
-       /* try to find the hash using the manifest */
+       // Try to find the hash using the manifest.
        direct_hash = common_hash;
        if (conf->direct_mode) {
                cc_log("Trying direct lookup");
@@ -3425,22 +3301,16 @@ ccache(int argc, char *argv[])
                if (object_hash) {
                        update_cached_result_globals(object_hash);
 
-                       /*
-                        * If we can return from cache at this point then do
-                        * so.
-                        */
+                       // If we can return from cache at this point then do so.
                        from_cache(FROMCACHE_DIRECT_MODE, 0);
 
-                       /*
-                        * Wasn't able to return from cache at this point.
-                        * However, the object was already found in manifest,
-                        * so don't readd it later.
-                        */
+                       // Wasn't able to return from cache at this point. However, the object
+                       // was already found in manifest, so don't readd it later.
                        put_object_in_manifest = false;
 
                        object_hash_from_manifest = object_hash;
                } else {
-                       /* Add object to manifest later. */
+                       // Add object to manifest later.
                        put_object_in_manifest = true;
                }
        }
@@ -3450,10 +3320,7 @@ ccache(int argc, char *argv[])
                failed();
        }
 
-       /*
-        * Find the hash using the preprocessed output. Also updates
-        * included_files.
-        */
+       // Find the hash using the preprocessed output. Also updates included_files.
        cpp_hash = common_hash;
        object_hash = calculate_object_hash(preprocessor_args, &cpp_hash, 0);
        if (!object_hash) {
@@ -3463,21 +3330,18 @@ ccache(int argc, char *argv[])
 
        if (object_hash_from_manifest
            && !file_hashes_equal(object_hash_from_manifest, object_hash)) {
-               /*
-                * The hash from manifest differs from the hash of the
-                * preprocessor output. This could be because:
-                *
-                * - The preprocessor produces different output for the same
-                *   input (not likely).
-                * - There's a bug in ccache (maybe incorrect handling of
-                *   compiler arguments).
-                * - The user has used a different CCACHE_BASEDIR (most
-                *   likely).
-                *
-                * The best thing here would probably be to remove the hash
-                * entry from the manifest. For now, we use a simpler method:
-                * just remove the manifest file.
-                */
+               // The hash from manifest differs from the hash of the preprocessor output.
+               // This could be because:
+               //
+               // - The preprocessor produces different output for the same input (not
+               //   likely).
+               // - There's a bug in ccache (maybe incorrect handling of compiler
+               //   arguments).
+               // - The user has used a different CCACHE_BASEDIR (most likely).
+               //
+               // The best thing here would probably be to remove the hash entry from the
+               // manifest. For now, we use a simpler method: just remove the manifest
+               // file.
                cc_log("Hash from manifest doesn't match preprocessor output");
                cc_log("Likely reason: different CCACHE_BASEDIRs used");
                cc_log("Removing manifest as a safety measure");
@@ -3486,7 +3350,7 @@ ccache(int argc, char *argv[])
                put_object_in_manifest = true;
        }
 
-       /* if we can return from cache at this point then do */
+       // If we can return from cache at this point then do.
        from_cache(FROMCACHE_CPP_MODE, put_object_in_manifest);
 
        if (conf->read_only) {
@@ -3496,7 +3360,7 @@ ccache(int argc, char *argv[])
 
        add_prefix(compiler_args, conf->prefix_command);
 
-       /* run real compiler, sending output to cache */
+       // Run real compiler, sending output to cache.
        to_cache(compiler_args);
 
        x_exit(0);
@@ -3509,7 +3373,7 @@ configuration_printer(const char *descr, const char *origin, void *context)
        fprintf(context, "(%s) %s\n", origin, descr);
 }
 
-/* the main program when not doing a compile */
+// The main program when not doing a compile.
 static int
 ccache_main_options(int argc, char *argv[])
 {
@@ -3540,23 +3404,23 @@ ccache_main_options(int argc, char *argv[])
                        manifest_dump(optarg, stdout);
                        break;
 
-               case 'c': /* --cleanup */
+               case 'c': // --cleanup
                        initialize();
                        cleanup_all(conf);
                        printf("Cleaned cache\n");
                        break;
 
-               case 'C': /* --clear */
+               case 'C': // --clear
                        initialize();
                        wipe_all(conf);
                        printf("Cleared cache\n");
                        break;
 
-               case 'h': /* --help */
+               case 'h': // --help
                        fputs(USAGE_TEXT, stdout);
                        x_exit(0);
 
-               case 'F': /* --max-files */
+               case 'F': // --max-files
                {
                        unsigned files;
                        initialize();
@@ -3574,7 +3438,7 @@ ccache_main_options(int argc, char *argv[])
                }
                break;
 
-               case 'M': /* --max-size */
+               case 'M': // --max-size
                {
                        uint64_t size;
                        initialize();
@@ -3596,7 +3460,7 @@ ccache_main_options(int argc, char *argv[])
                }
                break;
 
-               case 'o': /* --set-config */
+               case 'o': // --set-config
                {
                        char *errmsg, *key, *value, *p;
                        initialize();
@@ -3613,21 +3477,21 @@ ccache_main_options(int argc, char *argv[])
                }
                break;
 
-               case 'p': /* --print-config */
+               case 'p': // --print-config
                        initialize();
                        conf_print_items(conf, configuration_printer, stdout);
                        break;
 
-               case 's': /* --show-stats */
+               case 's': // --show-stats
                        initialize();
                        stats_summary(conf);
                        break;
 
-               case 'V': /* --version */
+               case 'V': // --version
                        fprintf(stdout, VERSION_TEXT, CCACHE_VERSION);
                        x_exit(0);
 
-               case 'z': /* --zero-stats */
+               case 'z': // --zero-stats
                        initialize();
                        stats_zero();
                        printf("Statistics cleared\n");
@@ -3645,15 +3509,15 @@ ccache_main_options(int argc, char *argv[])
 int
 ccache_main(int argc, char *argv[])
 {
-       /* check if we are being invoked as "ccache" */
+       // Check if we are being invoked as "ccache".
        char *program_name = basename(argv[0]);
        if (same_executable_name(program_name, MYNAME)) {
                if (argc < 2) {
                        fputs(USAGE_TEXT, stderr);
                        x_exit(1);
                }
-               /* if the first argument isn't an option, then assume we are
-                * being passed a compiler name and options */
+               // If the first argument isn't an option, then assume we are being passed a
+               // compiler name and options.
                if (argv[1][0] == '-') {
                        return ccache_main_options(argc, argv);
                }
index ae0906f59da8cc1a50e8cb89288b04f59ba953ee..3081d34ef39f1f3d3eb71509b21f48c0a0bfea1a 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -20,7 +20,7 @@
 
 extern const char CCACHE_VERSION[];
 
-/* statistics fields in storage order */
+// Statistics fields in storage order.
 enum stats {
        STATS_NONE = 0,
        STATS_STDOUT = 1,
@@ -61,22 +61,18 @@ enum stats {
 #define SLOPPY_FILE_MACRO 4
 #define SLOPPY_TIME_MACROS 8
 #define SLOPPY_PCH_DEFINES 16
-/*
- * Allow us to match files based on their stats (size, mtime, ctime), without
- * looking at their contents.
- */
+// Allow us to match files based on their stats (size, mtime, ctime), without
+// looking at their contents.
 #define SLOPPY_FILE_STAT_MATCHES 32
-/*
- * Allow us to not include any system headers in the manifest include files,
- * similar to -MM versus -M for dependencies.
- */
+// Allow us to not include any system headers in the manifest include files,
+// similar to -MM versus -M for dependencies.
 #define SLOPPY_NO_SYSTEM_HEADERS 64
 
 #define str_eq(s1, s2) (strcmp((s1), (s2)) == 0)
 #define str_startswith(s, p) (strncmp((s), (p), strlen((p))) == 0)
 
-/* ------------------------------------------------------------------------- */
-/* args.c */
+// ----------------------------------------------------------------------------
+// args.c
 
 struct args {
        char **argv;
@@ -99,8 +95,8 @@ void args_remove_first(struct args *args);
 char *args_to_string(struct args *args);
 bool args_equal(struct args *args1, struct args *args2);
 
-/* ------------------------------------------------------------------------- */
-/* hash.c */
+// ----------------------------------------------------------------------------
+// hash.c
 
 void hash_start(struct mdfour *md);
 void hash_buffer(struct mdfour *md, const void *s, size_t len);
@@ -114,8 +110,8 @@ void hash_int(struct mdfour *md, int x);
 bool hash_fd(struct mdfour *md, int fd);
 bool hash_file(struct mdfour *md, const char *fname);
 
-/* ------------------------------------------------------------------------- */
-/* util.c */
+// ----------------------------------------------------------------------------
+// util.c
 
 void cc_log(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
 void cc_bulklog(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
@@ -181,8 +177,8 @@ bool read_file(const char *path, size_t size_hint, char **data, size_t *size);
 char *read_text_file(const char *path, size_t size_hint);
 char *subst_env_in_string(const char *str, char **errmsg);
 
-/* ------------------------------------------------------------------------- */
-/* stats.c */
+// ----------------------------------------------------------------------------
+// stats.c
 
 void stats_update(enum stats stat);
 void stats_flush(void);
@@ -197,41 +193,41 @@ void stats_add_cleanup(const char *dir, unsigned count);
 void stats_read(const char *path, struct counters *counters);
 void stats_write(const char *path, struct counters *counters);
 
-/* ------------------------------------------------------------------------- */
-/* unify.c */
+// ----------------------------------------------------------------------------
+// unify.c
 
 int unify_hash(struct mdfour *hash, const char *fname);
 
-/* ------------------------------------------------------------------------- */
-/* exitfn.c */
+// ----------------------------------------------------------------------------
+// exitfn.c
 
 void exitfn_init(void);
 void exitfn_add_nullary(void (*function)(void));
 void exitfn_add(void (*function)(void *), void *context);
 void exitfn_call(void);
 
-/* ------------------------------------------------------------------------- */
-/* cleanup.c */
+// ----------------------------------------------------------------------------
+// cleanup.c
 
 void cleanup_dir(struct conf *conf, const char *dir);
 void cleanup_all(struct conf *conf);
 void wipe_all(struct conf *conf);
 
-/* ------------------------------------------------------------------------- */
-/* execute.c */
+// ----------------------------------------------------------------------------
+// execute.c
 
 int execute(char **argv, int fd_out, int fd_err, pid_t *pid);
 char *find_executable(const char *name, const char *exclude_name);
 void print_command(FILE *fp, char **argv);
 
-/* ------------------------------------------------------------------------- */
-/* lockfile.c */
+// ----------------------------------------------------------------------------
+// lockfile.c
 
 bool lockfile_acquire(const char *path, unsigned staleness_limit);
 void lockfile_release(const char *path);
 
-/* ------------------------------------------------------------------------- */
-/* ccache.c */
+// ----------------------------------------------------------------------------
+// ccache.c
 
 extern time_t time_of_compilation;
 void block_signals(void);
@@ -241,7 +237,7 @@ bool cc_process_args(struct args *args, struct args **preprocessor_args,
 void cc_reset(void);
 bool is_precompiled_header(const char *path);
 
-/* ------------------------------------------------------------------------- */
+// ----------------------------------------------------------------------------
 
 #if HAVE_COMPAR_FN_T
 #define COMPAR_FN_T __compar_fn_t
@@ -249,13 +245,12 @@ bool is_precompiled_header(const char *path);
 typedef int (*COMPAR_FN_T)(const void *, const void *);
 #endif
 
-/* work with silly DOS binary open */
+// Work with silly DOS binary open.
 #ifndef O_BINARY
 #define O_BINARY 0
 #endif
 
-/* mkstemp() on some versions of cygwin don't handle binary files, so
-   override */
+// mkstemp() on some versions of cygwin don't handle binary files, so override.
 #ifdef __CYGWIN__
 #undef HAVE_MKSTEMP
 #endif
@@ -289,4 +284,4 @@ void add_exe_ext_if_no_to_fullpath(char *full_path_win_ext, size_t max_size,
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
 #endif
 
-#endif /* ifndef CCACHE_H */
+#endif // ifndef CCACHE_H
index a273ca81d2aa6c708f33d8dff70f927fb471f123..972bc50500b6825f9bd3871433435aa0b79915c2 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -1,29 +1,25 @@
-/*
- * Copyright (C) 2002-2006 Andrew Tridgell
- * Copyright (C) 2009-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2002-2006 Andrew Tridgell
+// Copyright (C) 2009-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 
-/*
- * When "max files" or "max cache size" is reached, one of the 16 cache
- * subdirectories is cleaned up. When doing so, files are deleted (in LRU
- * order) until the levels are below LIMIT_MULTIPLE.
- */
+// When "max files" or "max cache size" is reached, one of the 16 cache
+// subdirectories is cleaned up. When doing so, files are deleted (in LRU
+// order) until the levels are below LIMIT_MULTIPLE.
 #define LIMIT_MULTIPLE 0.8
 
 static struct files {
@@ -31,15 +27,15 @@ static struct files {
        time_t mtime;
        uint64_t size;
 } **files;
-static unsigned allocated; /* Size of the files array. */
-static unsigned num_files; /* Number of used entries in the files array. */
+static unsigned allocated; // Size of the files array.
+static unsigned num_files; // Number of used entries in the files array.
 
 static uint64_t cache_size;
 static size_t files_in_cache;
 static uint64_t cache_size_threshold;
 static size_t files_in_cache_threshold;
 
-/* File comparison function that orders files in mtime order, oldest first. */
+// File comparison function that orders files in mtime order, oldest first.
 static int
 files_compare(struct files **f1, struct files **f2)
 {
@@ -52,7 +48,7 @@ files_compare(struct files **f1, struct files **f2)
        return 1;
 }
 
-/* this builds the list of files in the cache */
+// This builds the list of files in the cache.
 static void
 traverse_fn(const char *fname, struct stat *st)
 {
@@ -68,13 +64,12 @@ traverse_fn(const char *fname, struct stat *st)
        }
 
        if (str_startswith(p, ".nfs")) {
-               /* Ignore temporary NFS files that may be left for open but deleted
-                * files. */
+               // Ignore temporary NFS files that may be left for open but deleted files.
                goto out;
        }
 
        if (strstr(p, ".tmp.")) {
-               /* delete any tmp files older than 1 hour */
+               // Delete any tmp files older than 1 hour.
                if (st->st_mtime + 3600 < time(NULL)) {
                        x_unlink(fname);
                        goto out;
@@ -128,8 +123,8 @@ delete_sibling_file(const char *base, const char *extension)
        free(path);
 }
 
-/* sort the files we've found and delete the oldest ones until we are
-   below the thresholds */
+// Sort the files we've found and delete the oldest ones until we are below the
+// thresholds.
 static bool
 sort_and_clean(void)
 {
@@ -138,11 +133,11 @@ sort_and_clean(void)
        bool cleaned = false;
 
        if (num_files > 1) {
-               /* Sort in ascending mtime order. */
+               // Sort in ascending mtime order.
                qsort(files, num_files, sizeof(struct files *), (COMPAR_FN_T)files_compare);
        }
 
-       /* delete enough files to bring us below the threshold */
+       // Delete enough files to bring us below the threshold.
        for (i = 0; i < num_files; i++) {
                const char *ext;
 
@@ -161,25 +156,23 @@ sort_and_clean(void)
                    || str_eq(ext, ".stderr")
                    || str_eq(ext, "")) {
                        char *base = remove_extension(files[i]->fname);
-                       if (!str_eq(base, last_base)) { /* Avoid redundant unlinks. */
-                               /*
-                                * Make sure that all sibling files are deleted so that a cached result
-                                * is removed completely. Note the order of deletions -- the stderr
-                                * file must be deleted last because if the ccache process gets killed
-                                * after deleting the .stderr but before deleting the .o, the cached
-                                * result would be inconsistent.
-                                */
+                       if (!str_eq(base, last_base)) { // Avoid redundant unlinks.
+                               // Make sure that all sibling files are deleted so that a cached result
+                               // is removed completely. Note the order of deletions -- the stderr
+                               // file must be deleted last because if the ccache process gets killed
+                               // after deleting the .stderr but before deleting the .o, the cached
+                               // result would be inconsistent.
                                delete_sibling_file(base, ".o");
                                delete_sibling_file(base, ".d");
                                delete_sibling_file(base, ".gcno");
                                delete_sibling_file(base, ".dia");
                                delete_sibling_file(base, ".stderr");
-                               delete_sibling_file(base, ""); /* Object file from ccache 2.4. */
+                               delete_sibling_file(base, ""); // Object file from ccache 2.4.
                        }
                        free(last_base);
                        last_base = base;
                } else {
-                       /* .manifest or unknown file. */
+                       // .manifest or unknown file.
                        delete_file(files[i]->fname, files[i]->size);
                }
                cleaned = true;
@@ -188,7 +181,7 @@ sort_and_clean(void)
        return cleaned;
 }
 
-/* cleanup in one cache subdir */
+// Clean up one cache subdirectory.
 void
 cleanup_dir(struct conf *conf, const char *dir)
 {
@@ -204,10 +197,10 @@ cleanup_dir(struct conf *conf, const char *dir)
        cache_size = 0;
        files_in_cache = 0;
 
-       /* build a list of files */
+       // Build a list of files.
        traverse(dir, traverse_fn);
 
-       /* cleaned the cache */
+       // Clean the cache.
        cleaned = sort_and_clean();
 
        if (cleaned) {
@@ -217,7 +210,7 @@ cleanup_dir(struct conf *conf, const char *dir)
 
        stats_set_sizes(dir, files_in_cache, cache_size);
 
-       /* free it up */
+       // Free it up.
        for (i = 0; i < num_files; i++) {
                free(files[i]->fname);
                free(files[i]);
@@ -234,7 +227,7 @@ cleanup_dir(struct conf *conf, const char *dir)
        files_in_cache = 0;
 }
 
-/* cleanup in all cache subdirs */
+// Clean up all cache subdirectories.
 void cleanup_all(struct conf *conf)
 {
        int i;
@@ -246,7 +239,7 @@ void cleanup_all(struct conf *conf)
        }
 }
 
-/* traverse function for wiping files */
+// Traverse function for wiping files.
 static void wipe_fn(const char *fname, struct stat *st)
 {
        char *p;
@@ -267,7 +260,7 @@ static void wipe_fn(const char *fname, struct stat *st)
        x_unlink(fname);
 }
 
-/* wipe in one cache subdir */
+// Wipe one cache subdirectory.
 void
 wipe_dir(struct conf *conf, const char *dir)
 {
@@ -287,7 +280,7 @@ wipe_dir(struct conf *conf, const char *dir)
        files_in_cache = 0;
 }
 
-/* wipe all cached files in all subdirs */
+// Wipe all cached files in all subdirectories.
 void wipe_all(struct conf *conf)
 {
        int i;
@@ -298,6 +291,6 @@ void wipe_all(struct conf *conf)
                free(dname);
        }
 
-       /* and fix the counters */
+       // Fix the counters.
        cleanup_all(conf);
 }
index bb434ee4f56e3352e7f0870c023f5b7d88e2757c..901eef510393ee0ccfe279a276cd62b3c4d43f31 100644 (file)
--- a/compopt.c
+++ b/compopt.c
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2010-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 #include "compopt.h"
@@ -59,7 +57,7 @@ static const struct compopt compopts[] = {
        {"-b",              TAKES_ARG},
        {"-fmodules",       TOO_HARD},
        {"-fno-working-directory", AFFECTS_CPP},
-       {"-fplugin=libcc1plugin", TOO_HARD}, /* interaction with GDB */
+       {"-fplugin=libcc1plugin", TOO_HARD}, // interaction with GDB
        {"-frepo",          TOO_HARD},
        {"-fstack-usage",   TOO_HARD},
        {"-fworking-directory", AFFECTS_CPP},
@@ -69,7 +67,7 @@ static const struct compopt compopts[] = {
        {"-imultilib",      AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
        {"-include",        AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
        {"-include-pch",    AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
-       {"-install_name",   TAKES_ARG}, /* Darwin linker option */
+       {"-install_name",   TAKES_ARG}, // Darwin linker option
        {"-iprefix",        AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
        {"-iquote",         AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
        {"-isysroot",       AFFECTS_CPP | TAKES_ARG | TAKES_CONCAT_ARG | TAKES_PATH},
@@ -123,7 +121,7 @@ find_prefix(const char *option)
                 sizeof(compopts[0]), compare_prefix_compopts);
 }
 
-/* Runs fn on the first two characters of option. */
+// Runs fn on the first two characters of option.
 bool
 compopt_short(bool (*fn)(const char *), const char *option)
 {
@@ -133,7 +131,7 @@ compopt_short(bool (*fn)(const char *), const char *option)
        return retval;
 }
 
-/* For test purposes. */
+// For test purposes.
 bool
 compopt_verify_sortedness(void)
 {
@@ -192,13 +190,12 @@ compopt_takes_concat_arg(const char *option)
        return co && (co->type & TAKES_CONCAT_ARG);
 }
 
-/* Determines if the prefix of the option matches any option and affects the
- * preprocessor.
- */
+// Determines if the prefix of the option matches any option and affects the
+// preprocessor.
 bool
 compopt_prefix_affects_cpp(const char *option)
 {
-       /* prefix options have to take concatentated args */
+       // Prefix options have to take concatentated args.
        const struct compopt *co = find_prefix(option);
        return co && (co->type & TAKES_CONCAT_ARG) && (co->type & AFFECTS_CPP);
 }
index 109094b66a135352230a461c958789564b4540bb..d72639fe4d261f9a0eeb714093f679878feba581 100644 (file)
--- a/compopt.h
+++ b/compopt.h
@@ -12,4 +12,4 @@ bool compopt_takes_arg(const char *option);
 bool compopt_takes_concat_arg(const char *option);
 bool compopt_prefix_affects_cpp(const char *option);
 
-#endif /* CCACHE_COMPOPT_H */
+#endif // CCACHE_COMPOPT_H
diff --git a/conf.c b/conf.c
index ef465c508aa7c88cb6ca394b9518def157e61006..424c01e7a54c8e8acb3e3a7b563236d82bd26810 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2011-2015 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2011-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "conf.h"
 #include "ccache.h"
@@ -171,7 +169,7 @@ verify_absolute_path(void *value, char **errmsg)
        char **path = (char **)value;
        assert(*path);
        if (str_eq(*path, "")) {
-               /* The empty string means "disable" in this case. */
+               // The empty string means "disable" in this case.
                return true;
        } else if (is_absolute_path(*path)) {
                return true;
@@ -228,10 +226,8 @@ handle_conf_setting(struct conf *conf, const char *key, const char *value,
        }
 
        if (from_env_variable && item->parser == parse_bool) {
-               /*
-                * Special rule for boolean settings from the environment: any value means
-                * true.
-                */
+               // Special rule for boolean settings from the environment: any value means
+               // true.
                bool *value = (bool *)((char *)conf + item->offset);
                *value = !negate_boolean;
                goto out;
@@ -279,13 +275,13 @@ parse_line(const char *line, char **key, char **value, char **errmsg)
        }
        ++p;
 
-       /* Skip leading whitespace. */
+       // Skip leading whitespace.
        SKIP_WS(p);
        q = p;
        while (*q) {
                ++q;
        }
-       /* Skip trailing whitespace. */
+       // Skip trailing whitespace.
        while (isspace(q[-1])) {
                --q;
        }
@@ -296,7 +292,7 @@ parse_line(const char *line, char **key, char **value, char **errmsg)
 #undef SKIP_WS
 }
 
-/* Create a conf struct with default values. */
+// Create a conf struct with default values.
 struct conf *
 conf_create(void)
 {
@@ -330,7 +326,7 @@ conf_create(void)
        conf->sloppiness = 0;
        conf->stats = true;
        conf->temporary_dir = x_strdup("");
-       conf->umask = UINT_MAX; /* default: don't set umask */
+       conf->umask = UINT_MAX; // Default: don't set umask.
        conf->unify = false;
        conf->item_origins = x_malloc(CONFITEMS_TOTAL_KEYWORDS * sizeof(char *));
        for (i = 0; i < CONFITEMS_TOTAL_KEYWORDS; ++i) {
@@ -361,7 +357,7 @@ conf_free(struct conf *conf)
        free(conf);
 }
 
-/* Note: The path pointer is stored in conf, so path must outlive conf. */
+// Note: The path pointer is stored in conf, so path must outlive conf.
 bool
 conf_read(struct conf *conf, const char *path, char **errmsg)
 {
@@ -385,7 +381,7 @@ conf_read(struct conf *conf, const char *path, char **errmsg)
                bool ok;
                ++line_number;
                ok = parse_line(buf, &key, &value, &errmsg2);
-               if (ok && key) { /* key == NULL if comment or blank line */
+               if (ok && key) { // key == NULL if comment or blank line.
                        ok = handle_conf_setting(conf, key, value, &errmsg2, false, false, path);
                }
                free(key);
@@ -436,7 +432,7 @@ conf_update_from_environment(struct conf *conf, char **errmsg)
                }
                key = x_strndup(*p + key_start, q - *p - key_start);
 
-               ++q; /* Now points to the value. */
+               ++q; // Now points to the value.
 
                env_to_conf_item = find_env_to_conf(key);
                if (!env_to_conf_item) {
@@ -638,7 +634,7 @@ conf_print_items(struct conf *conf,
                reformat(&s, "%sno_system_headers, ", s);
        }
        if (conf->sloppiness) {
-               /* Strip last ", ". */
+               // Strip last ", ".
                s[strlen(s) - 2] = '\0';
        }
        printer(s, conf->item_origins[find_conf("sloppiness")->number], context);
index 4e3036a77c1c926350003efb5b17a884c70e8b42..af6b9c84854829295a0599aadf093a459925e1db 100644 (file)
@@ -1,29 +1,25 @@
-/*
- * Copyright (C) 2010 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
-/* A simple array of unsigned integers used for the statistics counters. */
+// A simple array of unsigned integers used for the statistics counters.
 
 #include "ccache.h"
 
-/*
- * Allocate and initialize a struct counters. Data entries up to the size are
- * set to 0.
- */
+// Allocate and initialize a struct counters. Data entries up to the size are
+// set to 0.
 struct counters *
 counters_init(size_t initial_size)
 {
@@ -35,9 +31,7 @@ counters_init(size_t initial_size)
        return c;
 }
 
-/*
- * Free a struct counters.
- */
+// Free a counters struct.
 void
 counters_free(struct counters *c)
 {
@@ -45,9 +39,7 @@ counters_free(struct counters *c)
        free(c);
 }
 
-/*
- * Set a new size. New data entries are set to 0.
- */
+// Set a new size. New data entries are set to 0.
 void
 counters_resize(struct counters *c, size_t new_size)
 {
index 345302bda83a9a9fd89f99411e3770adbae6d945..91dd75e2eaad79c74e752e23c446a51d77e2b14b 100644 (file)
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2010 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #ifndef COUNTERS_H
 #define COUNTERS_H
@@ -22,9 +20,9 @@
 #include <stddef.h>
 
 struct counters {
-       unsigned *data;   /* counter value */
-       size_t size;      /* logical array size */
-       size_t allocated; /* allocated size */
+       unsigned *data;   // counter value
+       size_t size;      // logical array size
+       size_t allocated; // allocated size
 };
 
 struct counters *counters_init(size_t initial_size);
index d7c75b8612f36453f6139006dd916d3d088f8137..344bce14bc52ca46887daec81579a5d5c5aa7b3a 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -1,21 +1,19 @@
-/*
- * Copyright (C) Andrew Tridgell 2002
- * Copyright (C) Joel Rosdahl 2011
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2002 Andrew Tridgell
+// Copyright (C) 2011-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 
@@ -25,10 +23,8 @@ static char *
 find_executable_in_path(const char *name, const char *exclude_name, char *path);
 
 #ifdef _WIN32
-/*
- * Re-create a win32 command line string based on **argv.
- * http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
- */
+// Re-create a win32 command line string based on **argv.
+// http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
 char *
 win32argvtos(char *prefix, char **argv)
 {
@@ -87,7 +83,7 @@ win32argvtos(char *prefix, char **argv)
                }
                *ptr++ = '"';
                *ptr++ = ' ';
-               /* cppcheck-suppress unreadVariable */
+               // cppcheck-suppress unreadVariable
        } while ((arg = argv[i++]));
        ptr[-1] = '\0';
 
@@ -106,7 +102,7 @@ win32getshell(char *path)
                sh = find_executable_in_path("sh.exe", NULL, path_env);
        }
        if (!sh && getenv("CCACHE_DETECT_SHEBANG")) {
-               /* Detect shebang. */
+               // Detect shebang.
                FILE *fp;
                fp = fopen(path, "r");
                if (fp) {
@@ -165,7 +161,7 @@ win32execute(char *path, char **argv, int doreturn,
                        return -1;
                }
        } else {
-               /* redirect subprocess stdout, stderr into current process */
+               // Redirect subprocess stdout, stderr into current process.
                si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
                si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
                si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
@@ -228,8 +224,8 @@ win32execute(char *path, char **argv, int doreturn,
 
 #else
 
-/* Execute a compiler backend, capturing all output to the given paths the full
- * path to the compiler to run is in argv[0]. */
+// Execute a compiler backend, capturing all output to the given paths the full
+// path to the compiler to run is in argv[0].
 int
 execute(char **argv, int fd_out, int fd_err, pid_t *pid)
 {
@@ -246,7 +242,7 @@ execute(char **argv, int fd_out, int fd_err, pid_t *pid)
        }
 
        if (*pid == 0) {
-               /* Child. */
+               // Child.
                dup2(fd_out, 1);
                close(fd_out);
                dup2(fd_err, 2);
@@ -273,11 +269,8 @@ execute(char **argv, int fd_out, int fd_err, pid_t *pid)
 }
 #endif
 
-
-/*
- * Find an executable by name in $PATH. Exclude any that are links to
- * exclude_name.
- */
+// Find an executable by name in $PATH. Exclude any that are links to
+// exclude_name.
 char *
 find_executable(const char *name, const char *exclude_name)
 {
@@ -306,8 +299,8 @@ find_executable_in_path(const char *name, const char *exclude_name, char *path)
 
        path = x_strdup(path);
 
-       /* search the path looking for the first compiler of the right name
-          that isn't us */
+       // Search the path looking for the first compiler of the right name that
+       // isn't us.
        for (tok = strtok_r(path, PATH_DELIM, &saveptr);
             tok;
             tok = strtok_r(NULL, PATH_DELIM, &saveptr)) {
@@ -329,7 +322,7 @@ find_executable_in_path(const char *name, const char *exclude_name, char *path)
 #else
                struct stat st1, st2;
                char *fname = format("%s/%s", tok, name);
-               /* look for a normal executable file */
+               // Look for a normal executable file.
                if (access(fname, X_OK) == 0 &&
                    lstat(fname, &st1) == 0 &&
                    stat(fname, &st2) == 0 &&
@@ -339,7 +332,7 @@ find_executable_in_path(const char *name, const char *exclude_name, char *path)
                                if (buf) {
                                        char *p = basename(buf);
                                        if (str_eq(p, exclude_name)) {
-                                               /* It's a link to "ccache"! */
+                                               // It's a link to "ccache"!
                                                free(p);
                                                free(buf);
                                                continue;
@@ -349,7 +342,7 @@ find_executable_in_path(const char *name, const char *exclude_name, char *path)
                                }
                        }
 
-                       /* Found it! */
+                       // Found it!
                        free(path);
                        return fname;
                }
index f59617a99df4be551962dcbcb9eee265cc929f62..ee61c0efddf4f15c942d80215783fb777bd91d55 100644 (file)
--- a/exitfn.c
+++ b/exitfn.c
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2010-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 
@@ -38,9 +36,7 @@ call_nullary_exit_function(void *context)
        free(p);
 }
 
-/*
- * Initialize exit functions. Must be called once before exitfn_add* are used.
- */
+// Initialize exit functions. Must be called once before exitfn_add* are used.
 void
 exitfn_init(void)
 {
@@ -49,10 +45,8 @@ exitfn_init(void)
        }
 }
 
-/*
- * Add a nullary function to be called when ccache exits. Functions are called
- * in reverse order.
- */
+// Add a nullary function to be called when ccache exits. Functions are called
+// in reverse order.
 void
 exitfn_add_nullary(void (*function)(void))
 {
@@ -61,10 +55,8 @@ exitfn_add_nullary(void (*function)(void))
        exitfn_add(call_nullary_exit_function, p);
 }
 
-/*
- * Add a function to be called with a context parameter when ccache exits.
- * Functions are called in reverse order.
- */
+// Add a function to be called with a context parameter when ccache exits.
+// Functions are called in reverse order.
 void
 exitfn_add(void (*function)(void *), void *context)
 {
@@ -77,9 +69,7 @@ exitfn_add(void (*function)(void *), void *context)
        exit_functions = p;
 }
 
-/*
- * Call added functions.
- */
+// Call added functions.
 void
 exitfn_call(void)
 {
diff --git a/hash.c b/hash.c
index 6f23bb94d842427e5a73157b4c2c765e49ec1dbe..028e6097aeef2cc670d9c348c49f9737a04e37b8 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -1,21 +1,19 @@
-/*
- * Copyright (C) 2002 Andrew Tridgell
- * Copyright (C) 2010 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2002 Andrew Tridgell
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 
@@ -33,7 +31,7 @@ hash_buffer(struct mdfour *md, const void *s, size_t len)
        mdfour_update(md, (unsigned char *)s, len);
 }
 
-/* Return the hash result as a hex string. Caller frees. */
+// Return the hash result as a hex string. Caller frees.
 char *
 hash_result(struct mdfour *md)
 {
@@ -43,7 +41,7 @@ hash_result(struct mdfour *md)
        return format_hash_as_string(sum, (unsigned) md->totalN);
 }
 
-/* return the hash result as 16 binary bytes */
+// Return the hash result as 16 binary bytes.
 void
 hash_result_as_bytes(struct mdfour *md, unsigned char *out)
 {
@@ -60,21 +58,19 @@ hash_equal(struct mdfour *md1, struct mdfour *md2)
        return memcmp(sum1, sum2, sizeof(sum1)) == 0;
 }
 
-/*
- * Hash some data that is unlikely to occur in the input. The idea is twofold:
- *
- * - Delimit things like arguments from each other (e.g., so that -I -O2 and
- *   -I-O2 hash differently).
- * - Tag different types of hashed information so that it's possible to do
- *   conditional hashing of information in a safe way (e.g., if we want to hash
- *   information X if CCACHE_A is set and information Y if CCACHE_B is set,
- *   there should never be a hash collision risk).
- */
+// Hash some data that is unlikely to occur in the input. The idea is twofold:
+//
+// - Delimit things like arguments from each other (e.g., so that -I -O2 and
+//   -I-O2 hash differently).
+// - Tag different types of hashed information so that it's possible to do
+//   conditional hashing of information in a safe way (e.g., if we want to hash
+//   information X if CCACHE_A is set and information Y if CCACHE_B is set,
+//   there should never be a hash collision risk).
 void
 hash_delimiter(struct mdfour *md, const char *type)
 {
        hash_buffer(md, HASH_DELIMITER, sizeof(HASH_DELIMITER));
-       hash_buffer(md, type, strlen(type) + 1); /* Include NUL. */
+       hash_buffer(md, type, strlen(type) + 1); // Include NUL.
 }
 
 void
@@ -95,10 +91,8 @@ hash_int(struct mdfour *md, int x)
        hash_buffer(md, (char *)&x, sizeof(x));
 }
 
-/*
- * Add contents of an open file to the hash. Returns true on success, otherwise
- * false.
- */
+// Add contents of an open file to the hash. Returns true on success, otherwise
+// false.
 bool
 hash_fd(struct mdfour *md, int fd)
 {
@@ -116,10 +110,8 @@ hash_fd(struct mdfour *md, int fd)
        return n == 0;
 }
 
-/*
- * Add contents of a file to the hash. Returns true on success, otherwise
- * false.
- */
+// Add contents of a file to the hash. Returns true on success, otherwise
+// false.
 bool
 hash_file(struct mdfour *md, const char *fname)
 {
index 1860f5306a5d8f2f11853288db3c5a03177b2e8a..1d0b7f9a3d7f59681767b03dc30ec0150591de0b 100644 (file)
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2009-2015 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2009-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 #include "hashutil.h"
@@ -46,39 +44,31 @@ file_hashes_equal(struct file_hash *fh1, struct file_hash *fh2)
               && fh1->size == fh2->size;
 }
 
-/*
- * Search for the strings "__DATE__" and "__TIME__" in str.
- *
- * Returns a bitmask with HASH_SOURCE_CODE_FOUND_DATE and
- * HASH_SOURCE_CODE_FOUND_TIME set appropriately.
- */
+// Search for the strings "__DATE__" and "__TIME__" in str.
+//
+// Returns a bitmask with HASH_SOURCE_CODE_FOUND_DATE and
+// HASH_SOURCE_CODE_FOUND_TIME set appropriately.
 int
 check_for_temporal_macros(const char *str, size_t len)
 {
        int result = 0;
 
-       /*
-        * We're using the Boyer-Moore-Horspool algorithm, which searches starting
-        * from the *end* of the needle. Our needles are 8 characters long, so i
-        * starts at 7.
-        */
+       // We're using the Boyer-Moore-Horspool algorithm, which searches starting
+       // from the *end* of the needle. Our needles are 8 characters long, so i
+       // starts at 7.
        size_t i = 7;
 
        while (i < len) {
-               /*
-                * Check whether the substring ending at str[i] has the form "__...E__". On
-                * the assumption that 'E' is less common in source than '_', we check
-                * str[i-2] first.
-                */
+               // Check whether the substring ending at str[i] has the form "__...E__". On
+               // the assumption that 'E' is less common in source than '_', we check
+               // str[i-2] first.
                if (str[i - 2] == 'E' &&
                    str[i - 0] == '_' &&
                    str[i - 7] == '_' &&
                    str[i - 1] == '_' &&
                    str[i - 6] == '_') {
-                       /*
-                        * Check the remaining characters to see if the substring is "__DATE__"
-                        * or "__TIME__".
-                        */
+                       // Check the remaining characters to see if the substring is "__DATE__"
+                       // or "__TIME__".
                        if (str[i - 5] == 'D' && str[i - 4] == 'A' &&
                            str[i - 3] == 'T') {
                                result |= HASH_SOURCE_CODE_FOUND_DATE;
@@ -88,19 +78,15 @@ check_for_temporal_macros(const char *str, size_t len)
                        }
                }
 
-               /*
-                * macro_skip tells us how far we can skip forward upon seeing str[i] at
-                * the end of a substring.
-                */
+               // macro_skip tells us how far we can skip forward upon seeing str[i] at
+               // the end of a substring.
                i += macro_skip[(uint8_t)str[i]];
        }
 
        return result;
 }
 
-/*
- * Hash a string. Returns a bitmask of HASH_SOURCE_CODE_* results.
- */
+// Hash a string. Returns a bitmask of HASH_SOURCE_CODE_* results.
 int
 hash_source_code_string(
   struct conf *conf, struct mdfour *hash, const char *str, size_t len,
@@ -108,24 +94,18 @@ hash_source_code_string(
 {
        int result = HASH_SOURCE_CODE_OK;
 
-       /*
-        * Check for __DATE__ and __TIME__ if the sloppiness configuration tells us
-        * we should.
-        */
+       // Check for __DATE__ and __TIME__ if the sloppiness configuration tells us
+       // we should.
        if (!(conf->sloppiness & SLOPPY_TIME_MACROS)) {
                result |= check_for_temporal_macros(str, len);
        }
 
-       /*
-        * Hash the source string.
-        */
+       // Hash the source string.
        hash_buffer(hash, str, len);
 
        if (result & HASH_SOURCE_CODE_FOUND_DATE) {
-               /*
-                * Make sure that the hash sum changes if the (potential) expansion of
-                * __DATE__ changes.
-                */
+               // Make sure that the hash sum changes if the (potential) expansion of
+               // __DATE__ changes.
                time_t t = time(NULL);
                struct tm *now = localtime(&t);
                cc_log("Found __DATE__ in %s", path);
@@ -135,24 +115,20 @@ hash_source_code_string(
                hash_buffer(hash, &now->tm_mday, sizeof(now->tm_mday));
        }
        if (result & HASH_SOURCE_CODE_FOUND_TIME) {
-               /*
-                * We don't know for sure that the program actually uses the __TIME__
-                * macro, but we have to assume it anyway and hash the time stamp. However,
-                * that's not very useful since the chance that we get a cache hit later
-                * the same second should be quite slim... So, just signal back to the
-                * caller that __TIME__ has been found so that the direct mode can be
-                * disabled.
-                */
+               // We don't know for sure that the program actually uses the __TIME__
+               // macro, but we have to assume it anyway and hash the time stamp. However,
+               // that's not very useful since the chance that we get a cache hit later
+               // the same second should be quite slim... So, just signal back to the
+               // caller that __TIME__ has been found so that the direct mode can be
+               // disabled.
                cc_log("Found __TIME__ in %s", path);
        }
 
        return result;
 }
 
-/*
- * Hash a file ignoring comments. Returns a bitmask of HASH_SOURCE_CODE_*
- * results.
- */
+// Hash a file ignoring comments. Returns a bitmask of HASH_SOURCE_CODE_*
+// results.
 int
 hash_source_code_file(struct conf *conf, struct mdfour *hash, const char *path)
 {
@@ -200,11 +176,11 @@ hash_command_output(struct mdfour *hash, const char *command,
 #endif
 
 #ifdef _WIN32
-       /* trim leading space */
+       // Trim leading space.
        while (isspace(*command)) {
                command++;
        }
-       /* add "echo" command */
+       // Add "echo" command.
        if (str_startswith(command, "echo")) {
                command = format("cmd.exe /c \"%s\"", command);
                cmd = true;
@@ -248,14 +224,14 @@ hash_command_output(struct mdfour *hash, const char *command,
        if (!cmd) {
                win32args = win32argvtos(sh, args->argv);
        } else {
-               win32args = (char *) command;  /* quoted */
+               win32args = (char *)command;  // quoted
        }
        ret = CreateProcess(path, win32args, NULL, NULL, 1, 0, NULL, NULL, &si, &pi);
        CloseHandle(pipe_out[1]);
        args_free(args);
        free(win32args);
        if (cmd) {
-               free((char *) command);  /* original argument was replaced above */
+               free((char *)command);  // Original argument was replaced above.
        }
        if (ret == 0) {
                stats_update(STATS_COMPCHECK);
@@ -288,15 +264,15 @@ hash_command_output(struct mdfour *hash, const char *command,
        }
 
        if (pid == 0) {
-               /* Child. */
+               // Child.
                close(pipefd[0]);
                close(0);
                dup2(pipefd[1], 1);
                dup2(pipefd[1], 2);
                _exit(execvp(args->argv[0], args->argv));
-               return false; /* Never reached. */
+               return false; // Never reached.
        } else {
-               /* Parent. */
+               // Parent.
                int status;
                bool ok;
                args_free(args);
index f544ef3f6daa63e16fab08c7fea00fe025d2d73f..452101094105c3642eb4515b7101cc4da13e64cb 100644 (file)
@@ -1,27 +1,23 @@
-/*
- * Copyright (C) 2010-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 
-/*
- * Supported file extensions and corresponding languages (as in parameter to
- * the -x option).
- */
+// Supported file extensions and corresponding languages (as in parameter to
+// the -x option).
 static const struct {
        const char *extension;
        const char *language;
@@ -43,13 +39,13 @@ static const struct {
        {".mm",  "objective-c++"},
        {".sx",  "assembler-with-cpp"},
        {".S",   "assembler-with-cpp"},
-       /* Preprocessed: */
+       // Preprocessed:
        {".i",   "cpp-output"},
        {".ii",  "c++-cpp-output"},
        {".mi",  "objective-c-cpp-output"},
        {".mii", "objective-c++-cpp-output"},
        {".s",   "assembler"},
-       /* Header file (for precompilation): */
+       // Header file (for precompilation):
        {".h",   "c-header"},
        {".H",   "c++-header"},
        {".h++", "c++-header"},
@@ -66,25 +62,25 @@ static const struct {
        {".TCC", "c++-header"},
        {".cu",  "cuda"},
        {".ic",  "cuda-output"},
-       /* Fixed form Fortran without preprocessing: */
+       // Fixed form Fortran without preprocessing:
        {".f",   "f77"},
        {".for", "f77"},
        {".ftn", "f77"},
-       /* Fixed form Fortran with traditional preprocessing: */
+       // Fixed form Fortran with traditional preprocessing:
        {".F",   "f77-cpp-input"},
        {".FOR", "f77-cpp-input"},
        {".fpp", "f77-cpp-input"},
        {".FPP", "f77-cpp-input"},
        {".FTN", "f77-cpp-input"},
-       /* Free form Fortran without preprocessing: */
-#if 0  /* Could generate modules, ignore for now! */
+       // Free form Fortran without preprocessing:
+#if 0  // Could generate modules, ignore for now!
        {".f90", "f95"},
        {".f95", "f95"},
        {".f03", "f95"},
        {".f08", "f95"},
 #endif
-       /* Free form Fortran with traditional preprocessing: */
-#if 0 /* Could generate modules, ignore for now! */
+       // Free form Fortran with traditional preprocessing:
+#if 0 // Could generate modules, ignore for now!
        {".F90", "f95-cpp-input"},
        {".F95", "f95-cpp-input"},
        {".F03", "f95-cpp-input"},
@@ -93,9 +89,7 @@ static const struct {
        {NULL,  NULL}
 };
 
-/*
- * Supported languages and corresponding preprocessed languages.
- */
+// Supported languages and corresponding preprocessed languages.
 static const struct {
        const char *language;
        const char *p_language;
@@ -119,17 +113,15 @@ static const struct {
        {"assembler",                "assembler"},
        {"f77-cpp-input",            "f77"},
        {"f77",                      "f77"},
-#if 0 /* Could generate module files, ignore for now! */
+#if 0 // Could generate module files, ignore for now!
        {"f95-cpp-input",            "f95"},
        {"f95",                      "f95"},
 #endif
        {NULL,  NULL}
 };
 
-/*
- * Guess the language of a file based on its extension. Returns NULL if the
- * extension is unknown.
- */
+// Guess the language of a file based on its extension. Returns NULL if the
+// extension is unknown.
 const char *
 language_for_file(const char *fname)
 {
@@ -145,9 +137,7 @@ language_for_file(const char *fname)
        return NULL;
 }
 
-/*
- * Return the preprocessed language for a given language, or NULL if unknown.
- */
+// Return the preprocessed language for a given language, or NULL if unknown.
 const char *
 p_language_for_language(const char *language)
 {
@@ -164,10 +154,8 @@ p_language_for_language(const char *language)
        return NULL;
 }
 
-/*
- * Return the default file extension (including dot) for a language, or NULL if
- * unknown.
- */
+// Return the default file extension (including dot) for a language, or NULL if
+// unknown.
 const char *
 extension_for_language(const char *language)
 {
index 21f87e8cd5a1d7990e831e0147cff82705a1a440..ebfb8bbd2a8a2ad099f112e78ddc8e9bef391d2c 100644 (file)
@@ -9,4 +9,4 @@ const char *extension_for_language(const char *language);
 bool language_is_supported(const char *language);
 bool language_is_preprocessed(const char *language);
 
-#endif /* CCACHE_LANGUAGE_H */
+#endif // CCACHE_LANGUAGE_H
index b565e610ad509b87f4db626230591dd99dc53620..a454a8734a3d56794d9b30d12b2a1d49b2fbc9b8 100644 (file)
@@ -1,33 +1,29 @@
-/*
- * Copyright (C) 2010-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 
-/*
- * This function acquires a lockfile for the given path. Returns true if the
- * lock was acquired, otherwise false. If the lock has been considered stale
- * for the number of microseconds specified by staleness_limit, the function
- * will (if possible) break the lock and then try to acquire it again. The
- * staleness limit should be reasonably larger than the longest time the lock
- * can be expected to be held, and the updates of the locked path should
- * probably be made with an atomic rename(2) to avoid corruption in the rare
- * case that the lock is broken by another process.
- */
+// This function acquires a lockfile for the given path. Returns true if the
+// lock was acquired, otherwise false. If the lock has been considered stale
+// for the number of microseconds specified by staleness_limit, the function
+// will (if possible) break the lock and then try to acquire it again. The
+// staleness limit should be reasonably larger than the longest time the lock
+// can be expected to be held, and the updates of the locked path should
+// probably be made with an atomic rename(2) to avoid corruption in the rare
+// case that the lock is broken by another process.
 bool
 lockfile_acquire(const char *path, unsigned staleness_limit)
 {
@@ -42,7 +38,7 @@ lockfile_acquire(const char *path, unsigned staleness_limit)
 #else
        int ret;
 #endif
-       unsigned to_sleep = 1000, slept = 0; /* Microseconds. */
+       unsigned to_sleep = 1000, slept = 0; // Microseconds.
 
        while (true) {
                free(my_content);
@@ -54,24 +50,22 @@ lockfile_acquire(const char *path, unsigned staleness_limit)
                        saved_errno = errno;
                        cc_log("lockfile_acquire: open WRONLY %s: %s", lockfile, strerror(errno));
                        if (saved_errno == ENOENT) {
-                               /* Directory doesn't exist? */
+                               // Directory doesn't exist?
                                if (create_parent_dirs(lockfile) == 0) {
-                                       /* OK. Retry. */
+                                       // OK. Retry.
                                        continue;
                                }
                        }
                        if (saved_errno != EEXIST) {
-                               /* Directory doesn't exist or isn't writable? */
+                               // Directory doesn't exist or isn't writable?
                                goto out;
                        }
-                       /* Someone else has the lock. */
+                       // Someone else has the lock.
                        fd = open(lockfile, O_RDONLY|O_BINARY);
                        if (fd == -1) {
                                if (errno == ENOENT) {
-                                       /*
-                                        * The file was removed after the open() call above, so retry
-                                        * acquiring it.
-                                        */
+                                       // The file was removed after the open() call above, so retry
+                                       // acquiring it.
                                        continue;
                                } else {
                                        cc_log("lockfile_acquire: open RDONLY %s: %s",
@@ -89,7 +83,7 @@ lockfile_acquire(const char *path, unsigned staleness_limit)
                        close(fd);
                        content[len] = '\0';
                } else {
-                       /* We got the lock. */
+                       // We got the lock.
                        if (write(fd, my_content, strlen(my_content)) == -1) {
                                cc_log("lockfile_acquire: write %s: %s", lockfile, strerror(errno));
                                close(fd);
@@ -103,40 +97,36 @@ lockfile_acquire(const char *path, unsigned staleness_limit)
 #else
                ret = symlink(my_content, lockfile);
                if (ret == 0) {
-                       /* We got the lock. */
+                       // We got the lock.
                        acquired = true;
                        goto out;
                }
                saved_errno = errno;
                cc_log("lockfile_acquire: symlink %s: %s", lockfile, strerror(saved_errno));
                if (saved_errno == ENOENT) {
-                       /* Directory doesn't exist? */
+                       // Directory doesn't exist?
                        if (create_parent_dirs(lockfile) == 0) {
-                               /* OK. Retry. */
+                               // OK. Retry.
                                continue;
                        }
                }
                if (saved_errno == EPERM) {
-                       /*
-                        * The file system does not support symbolic links. We have no choice but
-                        * to grant the lock anyway.
-                        */
+                       // The file system does not support symbolic links. We have no choice but
+                       // to grant the lock anyway.
                        acquired = true;
                        goto out;
                }
                if (saved_errno != EEXIST) {
-                       /* Directory doesn't exist or isn't writable? */
+                       // Directory doesn't exist or isn't writable?
                        goto out;
                }
                free(content);
                content = x_readlink(lockfile);
-               /* cppcheck-suppress nullPointer - false positive */
+               // cppcheck-suppress nullPointer - false positive
                if (!content) {
                        if (errno == ENOENT) {
-                               /*
-                                * The symlink was removed after the symlink() call above, so retry
-                                * acquiring it.
-                                */
+                               // The symlink was removed after the symlink() call above, so retry
+                               // acquiring it.
                                continue;
                        } else {
                                cc_log("lockfile_acquire: readlink %s: %s", lockfile, strerror(errno));
@@ -146,23 +136,21 @@ lockfile_acquire(const char *path, unsigned staleness_limit)
 #endif
 
                if (str_eq(content, my_content)) {
-                       /* Lost NFS reply? */
+                       // Lost NFS reply?
                        cc_log("lockfile_acquire: symlink %s failed but we got the lock anyway",
                               lockfile);
                        acquired = true;
                        goto out;
                }
-               /*
-                * A possible improvement here would be to check if the process holding the
-                * lock is still alive and break the lock early if it isn't.
-                */
+               // A possible improvement here would be to check if the process holding the
+               // lock is still alive and break the lock early if it isn't.
                cc_log("lockfile_acquire: lock info for %s: %s", lockfile, content);
                if (!initial_content) {
                        initial_content = x_strdup(content);
                }
                if (slept > staleness_limit) {
                        if (str_eq(content, initial_content)) {
-                               /* The lock seems to be stale -- break it. */
+                               // The lock seems to be stale -- break it.
                                cc_log("lockfile_acquire: breaking %s", lockfile);
                                if (lockfile_acquire(lockfile, staleness_limit)) {
                                        lockfile_release(path);
@@ -195,10 +183,8 @@ out:
        return acquired;
 }
 
-/*
- * Release the lockfile for the given path. Assumes that we are the legitimate
- * owner.
- */
+// Release the lockfile for the given path. Assumes that we are the legitimate
+// owner.
 void
 lockfile_release(const char *path)
 {
index e06e7c9a7827ee1c77c32c13eaed1eabd73e4ba0..75243fee90ade3503c4a8e5ea5c8cc6880e9b13d 100644 (file)
@@ -3,43 +3,41 @@
 
 #include <stdint.h>
 
-/*
- * A Boyer-Moore-Horspool skip table used for searching for the strings
- * "__TIME__" and "__DATE__".
- *
- * macro_skip[c] = 8 for all c not in "__TIME__" and "__DATE__".
- *
- * The other characters map as follows:
- *
- *   _ -> 1
- *   A -> 4
- *   D -> 5
- *   E -> 2
- *   I -> 4
- *   M -> 3
- *   T -> 3
- *
- *
- * This was generated with the following Python script:
- *
- * m = {'_': 1,
- *      'A': 4,
- *      'D': 5,
- *      'E': 2,
- *      'I': 4,
- *      'M': 3,
- *      'T': 3}
- *
- * for i in range(0, 256):
- *     if chr(i) in m:
- *         num = m[chr(i)]
- *     else:
- *         num = 8
- *     print ("%d, " % num),
- *
- *     if i % 16 == 15:
- *         print ""
- */
+// A Boyer-Moore-Horspool skip table used for searching for the strings
+// "__TIME__" and "__DATE__".
+//
+// macro_skip[c] = 8 for all c not in "__TIME__" and "__DATE__".
+//
+// The other characters map as follows:
+//
+//   _ -> 1
+//   A -> 4
+//   D -> 5
+//   E -> 2
+//   I -> 4
+//   M -> 3
+//   T -> 3
+//
+//
+// This was generated with the following Python script:
+//
+// m = {'_': 1,
+//      'A': 4,
+//      'D': 5,
+//      'E': 2,
+//      'I': 4,
+//      'M': 3,
+//      'T': 3}
+//
+// for i in range(0, 256):
+//     if chr(i) in m:
+//         num = m[chr(i)]
+//     else:
+//         num = 8
+//     print ("%d, " % num),
+//
+//     if i % 16 == 15:
+//         print ""
 
 static const uint32_t macro_skip[] = {
        8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,
diff --git a/main.c b/main.c
index 83c0abe4b4fab06b7bf86d97130d2e3a662d90a3..dda0b2e75865b9a8fe7925adb76880bfab30867a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,22 +1,20 @@
-/*
- * ccache -- a fast C/C++ compiler cache
- *
- * Copyright (C) 2010 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// ccache -- a fast C/C++ compiler cache
+//
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 int
 ccache_main(int argc, char *argv[]);
index 43ee01f8a2f2479f213d4ef4651abee4cd130313..bc555bd8b49dc769834a9634628b4ee7a158d5d9 100644 (file)
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2009-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2009-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 #include "hashtable_itr.h"
 
 #include <zlib.h>
 
-/*
- * Sketchy specification of the manifest disk format:
- *
- * <magic>         magic number                        (4 bytes)
- * <version>       file format version                 (1 byte unsigned int)
- * <hash_size>     size of the hash fields (in bytes)  (1 byte unsigned int)
- * <reserved>      reserved for future use             (2 bytes)
- * ----------------------------------------------------------------------------
- * <n>             number of include file paths        (4 bytes unsigned int)
- * <path_0>        path to include file                (NUL-terminated string,
- * ...                                                  at most 1024 bytes)
- * <path_n-1>
- * ----------------------------------------------------------------------------
- * <n>             number of include file hash entries (4 bytes unsigned int)
- * <index[0]>      index of include file path          (4 bytes unsigned int)
- * <hash[0]>       hash of include file                (<hash_size> bytes)
- * <size[0]>       size of include file                (4 bytes unsigned int)
- * <mtime[0]>      mtime of include file               (8 bytes signed int)
- * <ctime[0]>      ctime of include file               (8 bytes signed int)
- * ...
- * <index[n-1]>
- * <hash[n-1]>
- * <size[n-1]>
- * <mtime[n-1]>
- * <ctime[n-1]>
- * ----------------------------------------------------------------------------
- * <n>             number of object name entries       (4 bytes unsigned int)
- * <m[0]>          number of include file hash indexes (4 bytes unsigned int)
- * <index[0][0]>   include file hash index             (4 bytes unsigned int)
- * ...
- * <index[0][m[0]-1]>
- * <hash[0]>       hash part of object name            (<hash_size> bytes)
- * <size[0]>       size part of object name            (4 bytes unsigned int)
- * ...
- * <m[n-1]>        number of include file hash indexes
- * <index[n-1][0]> include file hash index
- * ...
- * <index[n-1][m[n-1]]>
- * <hash[n-1]>
- * <size[n-1]>
- */
+// Sketchy specification of the manifest disk format:
+//
+// <magic>         magic number                        (4 bytes)
+// <version>       file format version                 (1 byte unsigned int)
+// <hash_size>     size of the hash fields (in bytes)  (1 byte unsigned int)
+// <reserved>      reserved for future use             (2 bytes)
+// ----------------------------------------------------------------------------
+// <n>             number of include file paths        (4 bytes unsigned int)
+// <path_0>        path to include file                (NUL-terminated string,
+// ...                                                  at most 1024 bytes)
+// <path_n-1>
+// ----------------------------------------------------------------------------
+// <n>             number of include file hash entries (4 bytes unsigned int)
+// <index[0]>      index of include file path          (4 bytes unsigned int)
+// <hash[0]>       hash of include file                (<hash_size> bytes)
+// <size[0]>       size of include file                (4 bytes unsigned int)
+// <mtime[0]>      mtime of include file               (8 bytes signed int)
+// <ctime[0]>      ctime of include file               (8 bytes signed int)
+// ...
+// <index[n-1]>
+// <hash[n-1]>
+// <size[n-1]>
+// <mtime[n-1]>
+// <ctime[n-1]>
+// ----------------------------------------------------------------------------
+// <n>             number of object name entries       (4 bytes unsigned int)
+// <m[0]>          number of include file hash indexes (4 bytes unsigned int)
+// <index[0][0]>   include file hash index             (4 bytes unsigned int)
+// ...
+// <index[0][m[0]-1]>
+// <hash[0]>       hash part of object name            (<hash_size> bytes)
+// <size[0]>       size part of object name            (4 bytes unsigned int)
+// ...
+// <m[n-1]>        number of include file hash indexes
+// <index[n-1][0]> include file hash index
+// ...
+// <index[n-1][m[n-1]]>
+// <hash[n-1]>
+// <size[n-1]>
 
 static const uint32_t MAGIC = 0x63436d46U;
 static const uint32_t MAX_MANIFEST_ENTRIES = 100;
@@ -74,46 +70,46 @@ static const uint32_t MAX_MANIFEST_FILE_INFO_ENTRIES = 10000;
   do { enum { ccache_static_assert__ = 1/(e) }; } while (false)
 
 struct file_info {
-       /* Index to n_files. */
+       // Index to n_files.
        uint32_t index;
-       /* Hash of referenced file. */
+       // Hash of referenced file.
        uint8_t hash[16];
-       /* Size of referenced file. */
+       // Size of referenced file.
        uint32_t size;
-       /* mtime of referenced file. */
+       // mtime of referenced file.
        int64_t mtime;
-       /* ctime of referenced file. */
+       // ctime of referenced file.
        int64_t ctime;
 };
 
 struct object {
-       /* Number of entries in file_info_indexes. */
+       // Number of entries in file_info_indexes.
        uint32_t n_file_info_indexes;
-       /* Indexes to file_infos. */
+       // Indexes to file_infos.
        uint32_t *file_info_indexes;
-       /* Hash of the object itself. */
+       // Hash of the object itself.
        struct file_hash hash;
 };
 
 struct manifest {
-       /* Version of decoded file. */
+       // Version of decoded file.
        uint8_t version;
 
-       /* Reserved for future use. */
+       // Reserved for future use.
        uint16_t reserved;
 
-       /* Size of hash fields (in bytes). */
+       // Size of hash fields (in bytes).
        uint8_t hash_size;
 
-       /* Referenced include files. */
+       // Referenced include files.
        uint32_t n_files;
        char **files;
 
-       /* Information about referenced include files. */
+       // Information about referenced include files.
        uint32_t n_file_infos;
        struct file_info *file_infos;
 
-       /* Object names plus references to include file hashes. */
+       // Object names plus references to include file hashes.
        uint32_t n_objects;
        struct object *objects;
 };
@@ -127,7 +123,7 @@ struct file_stats {
 static unsigned int
 hash_from_file_info(void *key)
 {
-       ccache_static_assert(sizeof(struct file_info) == 40); /* No padding. */
+       ccache_static_assert(sizeof(struct file_info) == 40); // No padding.
        return murmurhashneutral2(key, sizeof(struct file_info), 0);
 }
 
@@ -259,7 +255,7 @@ read_manifest(gzFile f)
 
        READ_BYTE(mf->hash_size);
        if (mf->hash_size != 16) {
-               /* Temporary measure until we support different hash algorithms. */
+               // Temporary measure until we support different hash algorithms.
                cc_log("Manifest file has unsupported hash size %u", mf->hash_size);
                free_manifest(mf);
                return NULL;
@@ -401,11 +397,9 @@ verify_object(struct conf *conf, struct manifest *mf, struct object *obj,
                }
 
                if (conf->sloppiness & SLOPPY_FILE_STAT_MATCHES) {
-                       /*
-                        * st->ctime is sometimes 0, so we can't check that both st->ctime and
-                        * st->mtime are greater than time_of_compilation. But it's sufficient to
-                        * check that either is.
-                        */
+                       // st->ctime is sometimes 0, so we can't check that both st->ctime and
+                       // st->mtime are greater than time_of_compilation. But it's sufficient to
+                       // check that either is.
                        if (fi->size == st->size
                            && fi->mtime == st->mtime
                            && fi->ctime == st->ctime
@@ -515,14 +509,12 @@ get_file_hash_index(struct manifest *mf,
        memcpy(fi.hash, file_hash->hash, sizeof(fi.hash));
        fi.size = file_hash->size;
 
-       /*
-        * file_stat.st_{m,c}time has a resolution of 1 second, so we can cache the
-        * file's mtime and ctime only if they're at least one second older than
-        * time_of_compilation.
-        *
-        * st->ctime may be 0, so we have to check time_of_compilation against
-        * MAX(mtime, ctime).
-        */
+       // file_stat.st_{m,c}time has a resolution of 1 second, so we can cache the
+       // file's mtime and ctime only if they're at least one second older than
+       // time_of_compilation.
+       //
+       // st->ctime may be 0, so we have to check time_of_compilation against
+       // MAX(mtime, ctime).
 
        if (stat(path, &file_stat) != -1
            && time_of_compilation > MAX(file_stat.st_mtime, file_stat.st_ctime)) {
@@ -552,8 +544,8 @@ add_file_info_indexes(uint32_t *indexes, uint32_t size,
 {
        struct hashtable_itr *iter;
        uint32_t i;
-       struct hashtable *mf_files; /* path --> index */
-       struct hashtable *mf_file_infos; /* struct file_info --> index */
+       struct hashtable *mf_files; // path --> index
+       struct hashtable *mf_file_infos; // struct file_info --> index
 
        if (size == 0) {
                return;
@@ -597,24 +589,22 @@ add_object_entry(struct manifest *mf,
        obj->hash.size = object_hash->size;
 }
 
-/*
- * Try to get the object hash from a manifest file. Caller frees. Returns NULL
- * on failure.
- */
+// Try to get the object hash from a manifest file. Caller frees. Returns NULL
+// on failure.
 struct file_hash *
 manifest_get(struct conf *conf, const char *manifest_path)
 {
        int fd;
        gzFile f = NULL;
        struct manifest *mf = NULL;
-       struct hashtable *hashed_files = NULL; /* path --> struct file_hash */
-       struct hashtable *stated_files = NULL; /* path --> struct file_stats */
+       struct hashtable *hashed_files = NULL; // path --> struct file_hash
+       struct hashtable *stated_files = NULL; // path --> struct file_stats
        uint32_t i;
        struct file_hash *fh = NULL;
 
        fd = open(manifest_path, O_RDONLY | O_BINARY);
        if (fd == -1) {
-               /* Cache miss. */
+               // Cache miss.
                cc_log("No such manifest file");
                goto out;
        }
@@ -633,7 +623,7 @@ manifest_get(struct conf *conf, const char *manifest_path)
        hashed_files = create_hashtable(1000, hash_from_string, strings_equal);
        stated_files = create_hashtable(1000, hash_from_string, strings_equal);
 
-       /* Check newest object first since it's a bit more likely to match. */
+       // Check newest object first since it's a bit more likely to match.
        for (i = mf->n_objects; i > 0; i--) {
                if (verify_object(conf, mf, &mf->objects[i - 1],
                                  stated_files, hashed_files)) {
@@ -659,10 +649,8 @@ out:
        return fh;
 }
 
-/*
- * Put the object name into a manifest file given a set of included files.
- * Returns true on success, otherwise false.
- */
+// Put the object name into a manifest file given a set of included files.
+// Returns true on success, otherwise false.
 bool
 manifest_put(const char *manifest_path, struct file_hash *object_hash,
              struct hashtable *included_files)
@@ -674,15 +662,13 @@ manifest_put(const char *manifest_path, struct file_hash *object_hash,
        struct manifest *mf = NULL;
        char *tmp_file = NULL;
 
-       /*
-        * We don't bother to acquire a lock when writing the manifest to disk. A
-        * race between two processes will only result in one lost entry, which is
-        * not a big deal, and it's also very unlikely.
-        */
+       // We don't bother to acquire a lock when writing the manifest to disk. A
+       // race between two processes will only result in one lost entry, which is
+       // not a big deal, and it's also very unlikely.
 
        fd1 = open(manifest_path, O_RDONLY | O_BINARY);
        if (fd1 == -1) {
-               /* New file. */
+               // New file.
                mf = create_empty_manifest();
        } else {
                gzFile f1 = gzdopen(fd1, "rb");
@@ -701,27 +687,24 @@ manifest_put(const char *manifest_path, struct file_hash *object_hash,
        }
 
        if (mf->n_objects > MAX_MANIFEST_ENTRIES) {
-               /*
-                * Normally, there shouldn't be many object entries in the manifest since
-                * new entries are added only if an include file has changed but not the
-                * source file, and you typically change source files more often than
-                * header files. However, it's certainly possible to imagine cases where
-                * the manifest will grow large (for instance, a generated header file that
-                * changes for every build), and this must be taken care of since
-                * processing an ever growing manifest eventually will take too much time.
-                * A good way of solving this would be to maintain the object entries in
-                * LRU order and discarding the old ones. An easy way is to throw away all
-                * entries when there are too many. Let's do that for now.
-                */
+               // Normally, there shouldn't be many object entries in the manifest since
+               // new entries are added only if an include file has changed but not the
+               // source file, and you typically change source files more often than
+               // header files. However, it's certainly possible to imagine cases where
+               // the manifest will grow large (for instance, a generated header file that
+               // changes for every build), and this must be taken care of since
+               // processing an ever growing manifest eventually will take too much time.
+               // A good way of solving this would be to maintain the object entries in
+               // LRU order and discarding the old ones. An easy way is to throw away all
+               // entries when there are too many. Let's do that for now.
                cc_log("More than %u entries in manifest file; discarding",
                       MAX_MANIFEST_ENTRIES);
                free_manifest(mf);
                mf = create_empty_manifest();
        } else if (mf->n_file_infos > MAX_MANIFEST_FILE_INFO_ENTRIES) {
-               /* Rarely, file_info entries can grow large in pathological cases where
-                * many included files change, but the main file does not. This also puts
-                * an upper bound on the number of file_info entries.
-                */
+               // Rarely, file_info entries can grow large in pathological cases where
+               // many included files change, but the main file does not. This also puts
+               // an upper bound on the number of file_info entries.
                cc_log("More than %u file_info entries in manifest file; discarding",
                       MAX_MANIFEST_FILE_INFO_ENTRIES);
                free_manifest(mf);
index 30875dff1f8e691c2fb74cc1cc4c5070bd6459bd..702ad8da786ec3e346e0e7f8c537e0dceb1a062d 100644 (file)
--- a/mdfour.c
+++ b/mdfour.c
@@ -1,24 +1,23 @@
-/*
- * Copyright (C) 1997-1998 Andrew Tridgell
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 1997-1998 Andrew Tridgell
+// Copyright (C) 2009-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 
-/* NOTE: This code makes no attempt to be fast! */
+// NOTE: This code makes no attempt to be fast!
 
 static struct mdfour *m;
 
@@ -36,7 +35,7 @@ static struct mdfour *m;
 #define ROUND3(a, b, c, d, k, s) \
   a = lshift((a + H(b, c, d) + M[k] + 0x6ED9EBA1)&MASK32, s)
 
-/* this applies md4 to 64 byte chunks */
+// This applies md4 to 64 byte chunks.
 static void
 mdfour64(uint32_t *M)
 {
index cd891335aa0f4981a96fb56622d7bb5f37602584..8315fb17962ebf9aa2690a455415f08e4f85d9f5 100644 (file)
@@ -1,7 +1,5 @@
-/*
- * MurmurHashNeutral2, by Austin Appleby. Released to the public domain. See
- * <http://murmurhash.googlepages.com>.
- */
+// MurmurHashNeutral2, by Austin Appleby. Released to the public domain. See
+// <http://murmurhash.googlepages.com>.
 
 #include "murmurhashneutral2.h"
 
diff --git a/stats.c b/stats.c
index 22e634280452f5fe9a1e68dc8edb018d5eec5497..14577c48abb331618993347ccf05de1218962d87 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -1,26 +1,22 @@
-/*
- * Copyright (C) 2002-2004 Andrew Tridgell
- * Copyright (C) 2009-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Routines to handle the stats files. The stats file is stored one per cache
- * subdirectory to make this more scalable.
- */
+// Copyright (C) 2002-2004 Andrew Tridgell
+// Copyright (C) 2009-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+// Routines to handle the stats files. The stats file is stored one per cache
+// subdirectory to make this more scalable.
 
 #include "ccache.h"
 #include "hashutil.h"
@@ -41,13 +37,13 @@ extern char *secondary_config_path;
 
 static struct counters *counter_updates;
 
-#define FLAG_NOZERO 1 /* don't zero with the -z option */
-#define FLAG_ALWAYS 2 /* always show, even if zero */
-#define FLAG_NEVER 4 /* never show */
+#define FLAG_NOZERO 1 // don't zero with the -z option
+#define FLAG_ALWAYS 2 // always show, even if zero
+#define FLAG_NEVER 4 // never show
 
 static void display_size_times_1024(uint64_t size);
 
-/* statistics fields in display order */
+// Statistics fields in display order.
 static struct {
        enum stats stat;
        char *message;
@@ -104,7 +100,7 @@ display_size_times_1024(uint64_t size)
        display_size(size * 1024);
 }
 
-/* parse a stats file from a buffer - adding to the counters */
+// Parse a stats file from a buffer, adding to the counters.
 static void
 parse_stats(struct counters *counters, const char *buf)
 {
@@ -127,7 +123,7 @@ parse_stats(struct counters *counters, const char *buf)
        }
 }
 
-/* write out a stats file */
+// Write out a stats file.
 void
 stats_write(const char *path, struct counters *counters)
 {
@@ -155,10 +151,8 @@ init_counter_updates(void)
        }
 }
 
-/*
- * Record that a number of bytes and files have been added to the cache. Size
- * is in bytes.
- */
+// Record that a number of bytes and files have been added to the cache. Size
+// is in bytes.
 void
 stats_update_size(uint64_t size, unsigned files)
 {
@@ -167,7 +161,7 @@ stats_update_size(uint64_t size, unsigned files)
        counter_updates->data[STATS_TOTALSIZE] += size / 1024;
 }
 
-/* Read in the stats from one directory and add to the counters. */
+// Read in the stats from one directory and add to the counters.
 void
 stats_read(const char *sfile, struct counters *counters)
 {
@@ -178,9 +172,7 @@ stats_read(const char *sfile, struct counters *counters)
        free(data);
 }
 
-/*
- * Write counter updates in counter_updates to disk.
- */
+// Write counter updates in counter_updates to disk.
 void
 stats_flush(void)
 {
@@ -212,10 +204,8 @@ stats_flush(void)
        if (!stats_file) {
                char *stats_dir;
 
-               /*
-                * A NULL stats_file means that we didn't get past calculate_object_hash(),
-                * so we just choose one of stats files in the 16 subdirectories.
-                */
+               // A NULL stats_file means that we didn't get past calculate_object_hash(),
+               // so we just choose one of stats files in the 16 subdirectories.
                stats_dir = format("%s/%x", conf->cache_dir, hash_from_int(getpid()) % 16);
                stats_file = format("%s/stats", stats_dir);
                free(stats_dir);
@@ -259,7 +249,7 @@ stats_flush(void)
        counters_free(counters);
 }
 
-/* update a normal stat */
+// Update a normal stat.
 void
 stats_update(enum stats stat)
 {
@@ -268,7 +258,7 @@ stats_update(enum stats stat)
        counter_updates->data[stat]++;
 }
 
-/* Get the pending update of a counter value. */
+// Get the pending update of a counter value.
 unsigned
 stats_get_pending(enum stats stat)
 {
@@ -276,7 +266,7 @@ stats_get_pending(enum stats stat)
        return counter_updates->data[stat];
 }
 
-/* sum and display the total stats for all cache dirs */
+// Sum and display the total stats for all cache dirs.
 void
 stats_summary(struct conf *conf)
 {
@@ -288,7 +278,7 @@ stats_summary(struct conf *conf)
 
        assert(conf);
 
-       /* add up the stats in each directory */
+       // Add up the stats in each directory.
        for (dir = -1; dir <= 0xF; dir++) {
                char *fname;
 
@@ -308,7 +298,7 @@ stats_summary(struct conf *conf)
        printf("secondary config      (readonly)    %s\n",
               secondary_config_path ? secondary_config_path : "");
 
-       /* and display them */
+       // ...and display them.
        for (i = 0; stats_info[i].message; i++) {
                enum stats stat = stats_info[i].stat;
 
@@ -356,7 +346,7 @@ stats_summary(struct conf *conf)
        counters_free(counters);
 }
 
-/* zero all the stats structures */
+// Zero all the stats structures.
 void
 stats_zero(void)
 {
@@ -375,7 +365,7 @@ stats_zero(void)
                struct stat st;
                fname = format("%s/%1x/stats", conf->cache_dir, dir);
                if (stat(fname, &st) != 0) {
-                       /* No point in trying to reset the stats file if it doesn't exist. */
+                       // No point in trying to reset the stats file if it doesn't exist.
                        free(fname);
                        continue;
                }
@@ -394,7 +384,7 @@ stats_zero(void)
        }
 }
 
-/* Get the per directory limits */
+// Get the per-directory limits.
 void
 stats_get_obsolete_limits(const char *dir, unsigned *maxfiles,
                           uint64_t *maxsize)
@@ -408,7 +398,7 @@ stats_get_obsolete_limits(const char *dir, unsigned *maxfiles,
        counters_free(counters);
 }
 
-/* set the per directory sizes */
+// Set the per-directory sizes.
 void
 stats_set_sizes(const char *dir, unsigned num_files, uint64_t total_size)
 {
@@ -428,7 +418,7 @@ stats_set_sizes(const char *dir, unsigned num_files, uint64_t total_size)
        counters_free(counters);
 }
 
-/* count directory cleanup run */
+// Count directory cleanup run.
 void
 stats_add_cleanup(const char *dir, unsigned count)
 {
index f22ece8433c6f570019b3b8adbdc562f291caf95..0de03da70a08a363fa5244533579fd25168219a4 100644 (file)
--- a/system.h
+++ b/system.h
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2010-2015 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #ifndef CCACHE_SYSTEM_H
 #define CCACHE_SYSTEM_H
@@ -73,4 +71,4 @@ extern char **environ;
   #define asprintf rpl_asprintf
 #endif
 
-#endif /* CCACHE_SYSTEM_H */
+#endif // CCACHE_SYSTEM_H
diff --git a/test.sh b/test.sh
index 4975b0ef92fe2a3b406909cf6eaebae3c9bb9b4b..bf9bff8a875f1890841153b09dbe2d89c7941ab5 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -268,12 +268,12 @@ base_tests() {
 
     testname="CCACHE_COMMENTS"
     mv test1.c test1-saved.c
-    echo '/* initial comment */' > test1.c
+    echo '// initial comment' > test1.c
     cat test1-saved.c >> test1.c
     CCACHE_COMMENTS=1 $CCACHE_COMPILE -c test1.c
     checkstat 'cache hit (preprocessed)' 4
     checkstat 'cache miss' 3
-    echo '/* different comment */' > test1.c
+    echo '// different comment' > test1.c
     cat test1-saved.c >> test1.c
     CCACHE_COMMENTS=1 $CCACHE_COMPILE -c test1.c
     mv test1-saved.c test1.c
@@ -321,7 +321,7 @@ base_tests() {
     checkstat 'files in cache' 7
 
     testname="comments"
-    echo '/* a silly comment */' > test1-comment.c
+    echo '// a silly comment' > test1-comment.c
     cat test1.c >> test1-comment.c
     $CCACHE_COMPILE -c test1-comment.c
     rm -f test1-comment*
@@ -333,7 +333,7 @@ base_tests() {
     checkstat 'cache hit (preprocessed)' 6
     checkstat 'cache miss' 9
     mv test1.c test1-saved.c
-    echo '/* another comment */' > test1.c
+    echo '// another comment' > test1.c
     cat test1-saved.c >> test1.c
     CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c
     mv test1-saved.c test1.c
@@ -608,7 +608,7 @@ EOF
     cat <<EOF >stderr.c
 int stderr(void)
 {
-       /* Trigger warning by having no return statement. */
+       // Trigger warning by having no return statement.
 }
 EOF
     checkstat 'files in cache' 0
@@ -831,7 +831,7 @@ direct_suite() {
     ##################################################################
     # Create some code to compile.
     cat <<EOF >test.c
-/* test.c */
+// test.c
 #include "test1.h"
 #include "test2.h"
 EOF
@@ -846,7 +846,7 @@ EOF
 int test3;
 EOF
     cat <<EOF >code.c
-/* code.c */
+// code.c
 int test() { return 0; }
 EOF
     backdate test1.h test2.h test3.h
@@ -925,7 +925,7 @@ EOF
     mv test1.h test1.h.saved
     mv test3.h test3.h.saved
     cat <<EOF >test1.h
-/* No more include of test3.h */
+// No more include of test3.h
 int test1;
 EOF
     backdate test1.h
@@ -1229,11 +1229,11 @@ EOF
     $CCACHE -C >/dev/null
 cat <<EOF >cpp-warning.c
 #if FOO
-/* Trigger preprocessor warning about extra token after #endif. */
+// Trigger preprocessor warning about extra token after #endif.
 #endif FOO
 int stderr(void)
 {
-       /* Trigger compiler warning by having no return statement. */
+       // Trigger compiler warning by having no return statement.
 }
 EOF
     $CCACHE $COMPILER -Wall -W -c cpp-warning.c 2>stderr-orig.txt
@@ -1617,7 +1617,7 @@ EOF
     cat <<EOF >stderr.h
 int stderr(void)
 {
-       /* Trigger warning by having no return statement. */
+       // Trigger warning by having no return statement.
 }
 EOF
     cat <<EOF >stderr.c
@@ -2015,7 +2015,7 @@ ignoreheaders_suite() {
     testname="ignore headers in manifest"
     $CCACHE -Cz >/dev/null
     cat <<EOF >ignore.h
-/* We don't want this header in the manifest */
+// We don't want this header in the manifest.
 EOF
     backdate ignore.h
     cat <<EOF >ignore.c
index e4e6ac7b50cbd3a9e9b85cbb55ccd472a1dbf751..a36551e784e43c48ba4a7136f1b2d56fced37fcf 100644 (file)
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2010-2014 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "../ccache.h"
 #include "framework.h"
@@ -65,7 +63,7 @@ cct_run(suite_fn *suites, int verbose_output)
        suite_fn *suite;
        int tty = is_tty(1);
 
-       x_unsetenv("GCC_COLORS"); /* Avoid confusing argument processing tests. */
+       x_unsetenv("GCC_COLORS"); // Avoid confusing argument processing tests.
        verbose = verbose_output;
 
        for (suite = suites; *suite; suite++) {
@@ -73,7 +71,7 @@ cct_run(suite_fn *suites, int verbose_output)
                while (true) {
                        test_index = (*suite)(test_index + 1);
                        if (test_index == 0) {
-                               /* We have reached the end of the suite. */
+                               // We have reached the end of the suite.
                                break;
                        }
                }
@@ -262,7 +260,7 @@ cct_chdir(const char *path)
 void
 cct_wipe(const char *path)
 {
-       /* TODO: rewrite using traverse(). */
+       // TODO: rewrite using traverse().
 #ifndef __MINGW32__
        char *command = format("rm -rf %s", path);
 #else
index 72c12f6443d29abd29a9e8b09fa49af9d688b448..e8a33bb755aee60c8223de0ca5063a9f10a92fa4 100644 (file)
@@ -1,27 +1,25 @@
-/*
- * Copyright (C) 2010-2012 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #ifndef TEST_FRAMEWORK_H
 #define TEST_FRAMEWORK_H
 
 #include "../ccache.h"
 
-/*****************************************************************************/
+// ============================================================================
 
 #define TEST_SUITE(name) \
        unsigned suite_##name(unsigned _start_point) \
@@ -29,7 +27,7 @@
                unsigned _test_counter = 0; \
                cct_suite_begin(#name); \
                { \
-                       /* Empty due to macro trickery. */
+                       // Empty due to macro trickery.
 
 #define TEST(name) \
                        cct_test_end(); \
@@ -46,7 +44,7 @@
                return 0; /* We have reached the end. */ \
        }
 
-/*****************************************************************************/
+// ============================================================================
 
 #define CHECKM(assertion, message) \
        do { \
@@ -72,7 +70,7 @@
                } \
        } while (false)
 
-/*****************************************************************************/
+// ============================================================================
 
 #define CHECK_INT_EQ(expected, actual) \
        do { \
@@ -84,7 +82,7 @@
                } \
        } while (false)
 
-/*****************************************************************************/
+// ============================================================================
 
 #define CHECK_STR_EQ(expected, actual) \
        CHECK_POINTER_EQ_BASE(str, expected, actual, false, false)
@@ -98,7 +96,7 @@
 #define CHECK_STR_EQ_FREE12(expected, actual) \
        CHECK_POINTER_EQ_BASE(str, expected, actual, true, true)
 
-/*****************************************************************************/
+// ============================================================================
 
 #define CHECK_ARGS_EQ(expected, actual) \
        CHECK_POINTER_EQ_BASE(args, expected, actual, false, false)
 #define CHECK_ARGS_EQ_FREE12(expected, actual) \
        CHECK_POINTER_EQ_BASE(args, expected, actual, true, true)
 
-/*****************************************************************************/
+// ============================================================================
 
 typedef unsigned (*suite_fn)(unsigned);
 int cct_run(suite_fn *suites, int verbose);
index aa4bf400866eeb1a2687ae4c71b85e63cb715f4f..965ffeda64c35d302fe98e7a22563af3542c47d8 100644 (file)
@@ -1,21 +1,18 @@
-/* Mode: -*-c-*- */
-/*
- * Copyright (C) 2010 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "framework.h"
 #ifdef HAVE_GETOPT_LONG
 #include "../getopt_long.h"
 #endif
 
-/* *INDENT-OFF* disable uncrustify */
+// *INDENT-OFF* disable uncrustify
 #define SUITE(name) unsigned suite_ ## name(unsigned);
-#include "test/suites.h"
+#include "suites.h"
 #undef SUITE
-/* *INDENT-ON* enable uncrustify */
+// *INDENT-ON* enable uncrustify
 
 const char USAGE_TEXT[] =
   "Usage:\n"
index be0c7e736ced35d2d08ff99c1d7cd67c2788d6c1..6b11dc4565e10b47317335ed8bf2c5ddbec461ed 100644 (file)
@@ -1,24 +1,20 @@
-/*
- * Copyright (C) 2010, 2012 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This file contains tests for the functions operating on struct args.
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+// This file contains tests for the functions operating on struct args.
 
 #include "../ccache.h"
 #include "framework.h"
index 7d61317e85518eedfc94c72f5faa0bbc01c128e1..5fb244a3311d9e2422824d427160fc2e556c4977 100644 (file)
@@ -1,24 +1,20 @@
-/*
- * Copyright (C) 2010-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This file contains tests for the processing of compiler arguments.
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+// This file contains tests for the processing of compiler arguments.
 
 #include "../ccache.h"
 #include "../conf.h"
@@ -33,7 +29,7 @@ get_root(void)
 #ifndef _WIN32
        return x_strdup("/");
 #else
-       char volume[4]; /* "C:\" */
+       char volume[4]; // "C:\"
        GetVolumePathName(get_cwd(), volume, sizeof(volume));
        return x_strdup(volume);
 #endif
@@ -48,13 +44,13 @@ get_posix_path(char *path)
        char *posix;
        char *p;
 
-       /* / escape volume */
+       // /-escape volume.
        if (path[0] >= 'A' && path[0] <= 'Z' && path[1] == ':') {
                posix = format("/%s", path);
        } else {
                posix = x_strdup(path);
        }
-       /* convert slashes */
+       // Convert slashes.
        for (p = posix; *p; p++) {
                if (*p == '\\') {
                        *p = '/';
@@ -370,9 +366,9 @@ TEST(isystem_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
 
        create_file("foo.c", "");
        free(conf->base_dir);
-       conf->base_dir = x_strdup("/"); /* posix */
+       conf->base_dir = x_strdup("/"); // posix
        current_working_dir = get_cwd();
-       /* windows path don't work concatenated */
+       // Windows path doesn't work concatenated.
        cwd = get_posix_path(current_working_dir);
        arg_string = format("cc -isystem%s/foo -c foo.c", cwd);
        orig = args_init_from_string(arg_string);
@@ -397,9 +393,9 @@ TEST(I_flag_with_concat_arg_should_be_rewritten_if_basedir_is_used)
 
        create_file("foo.c", "");
        free(conf->base_dir);
-       conf->base_dir = x_strdup("/"); /* posix */
+       conf->base_dir = x_strdup("/"); // posix
        current_working_dir = get_cwd();
-       /* windows path don't work concatenated */
+       // Windows path doesn't work concatenated.
        cwd = get_posix_path(current_working_dir);
        arg_string = format("cc -I%s/foo -c foo.c", cwd);
        orig = args_init_from_string(arg_string);
index 3d0aa64de6c0fcbe48680598616694bef89b7fd6..dc1e74c1b22adc33a997e711813b60b9d272584f 100644 (file)
@@ -1,24 +1,20 @@
-/*
- * Copyright (C) 2010, 2012 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This file contains tests for the compopt_* functions.
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+// This file contains tests for the compopt_* functions.
 
 #include "../ccache.h"
 #include "../compopt.h"
index e2de4e9090d218f78b1f1c3125b79480719bc640..90f99fd9346847187b9e9edae840ab728a314744 100644 (file)
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2011-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2011-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "../conf.h"
 #include "framework.h"
@@ -130,7 +128,7 @@ TEST(conf_read_valid_config)
          "stats = false\n"
          "temporary_dir = ${USER}_foo\n"
          "umask = 777\n"
-         "unify = true"); /* Note: no newline */
+         "unify = true"); // Note: no newline.
        CHECK(conf_read(conf, "ccache.conf", &errmsg));
        CHECK(!errmsg);
 
@@ -223,7 +221,7 @@ TEST(conf_read_invalid_env_string)
        CHECK(!conf_read(conf, "ccache.conf", &errmsg));
        CHECK_STR_EQ_FREE2("ccache.conf:1: syntax error: missing '}' after \"foo\"",
                           errmsg);
-       /* Other cases tested in test_util.c. */
+       // Other cases tested in test_util.c.
        conf_free(conf);
 }
 
@@ -245,7 +243,7 @@ TEST(conf_read_invalid_size)
        CHECK(!conf_read(conf, "ccache.conf", &errmsg));
        CHECK_STR_EQ_FREE2("ccache.conf:1: invalid size: \"foo\"",
                           errmsg);
-       /* Other cases tested in test_util.c. */
+       // Other cases tested in test_util.c.
        conf_free(conf);
 }
 
index 37e26fc75798ed03726e342e1c19578e9f2ea903..1705b7621e5a990a13b0e4bfefea97fd8db7a374 100644 (file)
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2010-2011 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2011 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "../ccache.h"
 #include "../counters.h"
index 7042ca3c0c870379e180a593ff8262dcc8556ead..3fe3d6951163edf051c944bd36f2f9336597ecfa 100644 (file)
@@ -1,24 +1,20 @@
-/*
- * Copyright (C) 2010 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This file contains tests for functions in hash.c.
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+// This file contains tests for functions in hash.c.
 
 #include "../ccache.h"
 #include "framework.h"
index f92597a6338032d5e325577b35e09310f217f93c..22930c96e9dbc60dcf9d57d80caff17e6ba9c2f1 100644 (file)
@@ -1,24 +1,20 @@
-/*
- * Copyright (C) 2010, 2012 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This file contains tests for functions in hashutil.c.
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+// This file contains tests for functions in hashutil.c.
 
 #include "../ccache.h"
 #include "../hashutil.h"
index e7a6742d27b25564c37d19d33d2491ce1b5e61ae..cb7617683f12937b4ce5dcf8c8234d7971971d7c 100644 (file)
@@ -1,24 +1,20 @@
-/*
- * Copyright (C) 2010 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
-/*
- * This file contains tests for functions in lockfile.c.
- */
+// This file contains tests for functions in lockfile.c.
 
 #include "../ccache.h"
 #include "framework.h"
index a8abad378607dcfd2ac0e78c30319342f17ba5bc..2815b9e9be464aa15a0e66cc9daf0f0db7b982aa 100644 (file)
@@ -1,24 +1,20 @@
-/*
- * Copyright (C) 2010-2011 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This file contains tests for statistics handling.
- */
+// Copyright (C) 2010-2011 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+// This file contains tests for statistics handling.
 
 #include "../ccache.h"
 #include "../counters.h"
index 89bbb935c30310e585576aeeebc430ee39ed845b..dca718c34e783631235663218d0d2982d2e2632e 100644 (file)
@@ -1,24 +1,20 @@
-/*
- * Copyright (C) 2010-2015 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This file contains tests for functions in util.c.
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+// This file contains tests for functions in util.c.
 
 #include "../ccache.h"
 #include "framework.h"
@@ -180,7 +176,7 @@ TEST(parse_size_with_suffix)
        size_t i;
        struct { const char *size; int64_t expected; } sizes[] = {
                {"0", 0},
-               {"42", (int64_t)42 * 1000 * 1000 * 1000}, /* Default suffix: G */
+               {"42", (int64_t)42 * 1000 * 1000 * 1000}, // Default suffix: G
 
                {"78k",       78 * 1000},
                {"78K",       78 * 1000},
index ba91f072c1a80b6438ea0c9fd11ee4c419ded46f..826eebdcbaa3abc86babaeaa6ac494ce3c15dded 100644 (file)
@@ -1,20 +1,18 @@
-/*
- * Copyright (C) 2010-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2010-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "../system.h"
 #include "util.h"
diff --git a/unify.c b/unify.c
index 6f19ea809500f3de9fd4b27fc586102bc47420fa..230bcdb356c8ef581e6aa1c457db683ad4cbecc3 100644 (file)
--- a/unify.c
+++ b/unify.c
@@ -1,34 +1,31 @@
-/*
- * Copyright (C) 2002 Andrew Tridgell
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2002 Andrew Tridgell
+// Copyright (C) 2009-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
-/*
- * C/C++ unifier
- *
- * The idea is that changes that don't affect the resulting C code should not
- * change the hash. This is achieved by folding white-space and other
- * non-semantic fluff in the input into a single unified format.
- *
- * This unifier was design to match the output of the unifier in compilercache,
- * which is flex based. The major difference is that this unifier is much
- * faster (about 2x) and more forgiving of syntactic errors. Continuing on
- * syntactic errors is important to cope with C/C++ extensions in the local
- * compiler (for example, inline assembly systems).
- */
+// C/C++ unifier
+//
+// The idea is that changes that don't affect the resulting C code should not
+// change the hash. This is achieved by folding white-space and other
+// non-semantic fluff in the input into a single unified format.
+//
+// This unifier was design to match the output of the unifier in compilercache,
+// which is flex based. The major difference is that this unifier is much
+// faster (about 2x) and more forgiving of syntactic errors. Continuing on
+// syntactic errors is important to cope with C/C++ extensions in the local
+// compiler (for example, inline assembly systems).
 
 #include "ccache.h"
 
@@ -56,7 +53,7 @@ static struct {
        const char *toks[7];
 } tokens[256];
 
-/* build up the table used by the unifier */
+// Build up the table used by the unifier.
 static void
 build_table(void)
 {
@@ -104,7 +101,7 @@ build_table(void)
        }
 }
 
-/* buffer up characters before hashing them */
+// Buffer up characters before hashing them.
 static void
 pushchar(struct mdfour *hash, unsigned char c)
 {
@@ -127,7 +124,7 @@ pushchar(struct mdfour *hash, unsigned char c)
        }
 }
 
-/* hash some C/C++ code after unifying */
+// Hash some C/C++ code after unifying.
 static void
 unify(struct mdfour *hash, unsigned char *p, size_t size)
 {
@@ -244,9 +241,8 @@ unify(struct mdfour *hash, unsigned char *p, size_t size)
 }
 
 
-/* hash a file that consists of preprocessor output, but remove any line
-   number information from the hash
- */
+// Hash a file that consists of preprocessor output, but remove any line number
+// information from the hash.
 int
 unify_hash(struct mdfour *hash, const char *fname)
 {
diff --git a/util.c b/util.c
index b242841a3ae02a8430aefd890a76a1b80e47b0f8..457a4054fb70371d3df8bff90e3038c37f33d6e3 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,21 +1,19 @@
-/*
- * Copyright (C) 2002 Andrew Tridgell
- * Copyright (C) 2009-2016 Joel Rosdahl
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 3 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
+// Copyright (C) 2002 Andrew Tridgell
+// Copyright (C) 2009-2016 Joel Rosdahl
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+// more details.
+//
+// You should have received a copy of the GNU General Public License along with
+// this program; if not, write to the Free Software Foundation, Inc., 51
+// Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 #include "ccache.h"
 
@@ -109,15 +107,13 @@ path_max(const char *path)
 #endif
 }
 
-/*
- * Warn about failure writing to the log file and then exit.
- */
+// Warn about failure writing to the log file and then exit.
 static void
 warn_log_fail(void)
 {
        extern struct conf *conf;
 
-       /* Note: Can't call fatal() since that would lead to recursion. */
+       // Note: Can't call fatal() since that would lead to recursion.
        fprintf(stderr, "ccache: error: Failed to write to %s: %s\n",
                conf->log_file, strerror(errno));
        x_exit(EXIT_FAILURE);
@@ -139,9 +135,7 @@ vlog(const char *format, va_list ap, bool log_updated_time)
        }
 }
 
-/*
- * Write a message to the log file (adding a newline) and flush.
- */
+// Write a message to the log file (adding a newline) and flush.
 void
 cc_log(const char *format, ...)
 {
@@ -154,10 +148,8 @@ cc_log(const char *format, ...)
        }
 }
 
-/*
- * Write a message to the log file (adding a newline) without flushing and with
- * a reused timestamp.
- */
+// Write a message to the log file (adding a newline) without flushing and with
+// a reused timestamp.
 void
 cc_bulklog(const char *format, ...)
 {
@@ -167,9 +159,7 @@ cc_bulklog(const char *format, ...)
        va_end(ap);
 }
 
-/*
- * Log an executed command to the CCACHE_LOGFILE location.
- */
+// Log an executed command to the CCACHE_LOGFILE location.
 void
 cc_log_argv(const char *prefix, char **argv)
 {
@@ -187,7 +177,7 @@ cc_log_argv(const char *prefix, char **argv)
        }
 }
 
-/* something went badly wrong! */
+// Something went badly wrong!
 void
 fatal(const char *format, ...)
 {
@@ -204,9 +194,7 @@ fatal(const char *format, ...)
        x_exit(1);
 }
 
-/*
- * Copy all data from fd_in to fd_out, decompressing data from fd_in if needed.
- */
+// Copy all data from fd_in to fd_out, decompressing data from fd_in if needed.
 void
 copy_fd(int fd_in, int fd_out)
 {
@@ -238,7 +226,7 @@ copy_fd(int fd_in, int fd_out)
 }
 
 #ifndef HAVE_MKSTEMP
-/* cheap and nasty mkstemp replacement */
+// Cheap and nasty mkstemp replacement.
 int
 mkstemp(char *template)
 {
@@ -262,11 +250,9 @@ get_umask(void)
 }
 #endif
 
-/*
- * Copy src to dest, decompressing src if needed. compress_level > 0 decides
- * whether dest will be compressed, and with which compression level. Returns 0
- * on success and -1 on failure. On failure, errno represents the error.
- */
+// Copy src to dest, decompressing src if needed. compress_level > 0 decides
+// whether dest will be compressed, and with which compression level. Returns 0
+// on success and -1 on failure. On failure, errno represents the error.
 int
 copy_file(const char *src, const char *dest, int compress_level)
 {
@@ -279,13 +265,13 @@ copy_file(const char *src, const char *dest, int compress_level)
        int errnum;
        int saved_errno = 0;
 
-       /* open destination file */
+       // Open destination file.
        tmp_name = x_strdup(dest);
        fd_out = create_tmp_fd(&tmp_name);
        cc_log("Copying %s to %s via %s (%scompressed)",
               src, dest, tmp_name, compress_level > 0 ? "" : "un");
 
-       /* open source file */
+       // Open source file.
        fd_in = open(src, O_RDONLY | O_BINARY);
        if (fd_in == -1) {
                saved_errno = errno;
@@ -302,11 +288,9 @@ copy_file(const char *src, const char *dest, int compress_level)
        }
 
        if (compress_level > 0) {
-               /*
-                * A gzip file occupies at least 20 bytes, so it will always
-                * occupy an entire filesystem block, even for empty files.
-                * Turn off compression for empty files to save some space.
-                */
+               // A gzip file occupies at least 20 bytes, so it will always occupy an
+               // entire filesystem block, even for empty files. Turn off compression for
+               // empty files to save some space.
                if (x_fstat(fd_in, &st) != 0) {
                        goto error;
                }
@@ -351,10 +335,8 @@ copy_file(const char *src, const char *dest, int compress_level)
                }
        }
 
-       /*
-        * gzeof won't tell if there's an error in the trailing CRC, so we must check
-        * gzerror before considering everything OK.
-        */
+       // gzeof won't tell if there's an error in the trailing CRC, so we must check
+       // gzerror before considering everything OK.
        gzerror(gz_in, &errnum);
        if (!gzeof(gz_in) || (errnum != Z_OK && errnum != Z_STREAM_END)) {
                saved_errno = errno;
@@ -381,7 +363,7 @@ copy_file(const char *src, const char *dest, int compress_level)
        fchmod(fd_out, 0666 & ~get_umask());
 #endif
 
-       /* the close can fail on NFS if out of space */
+       // The close can fail on NFS if out of space.
        if (close(fd_out) == -1) {
                saved_errno = errno;
                cc_log("close error: %s", strerror(saved_errno));
@@ -414,7 +396,7 @@ error:
        return -1;
 }
 
-/* Run copy_file() and, if successful, delete the source file. */
+// Run copy_file() and, if successful, delete the source file.
 int
 move_file(const char *src, const char *dest, int compress_level)
 {
@@ -427,10 +409,8 @@ move_file(const char *src, const char *dest, int compress_level)
        return ret;
 }
 
-/*
- * Like move_file(), but assumes that src is uncompressed and that src and dest
- * are on the same file system.
- */
+// Like move_file(), but assumes that src is uncompressed and that src and dest
+// are on the same file system.
 int
 move_uncompressed_file(const char *src, const char *dest, int compress_level)
 {
@@ -441,7 +421,7 @@ move_uncompressed_file(const char *src, const char *dest, int compress_level)
        }
 }
 
-/* test if a file is zlib compressed */
+// Test if a file is zlib compressed.
 bool
 file_is_compressed(const char *filename)
 {
@@ -452,8 +432,7 @@ file_is_compressed(const char *filename)
                return false;
        }
 
-       /* test if file starts with 1F8B, which is zlib's
-        * magic number */
+       // Test if file starts with 1F8B, which is zlib's magic number.
        if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) {
                fclose(f);
                return false;
@@ -463,7 +442,7 @@ file_is_compressed(const char *filename)
        return true;
 }
 
-/* make sure a directory exists */
+// Make sure a directory exists.
 int
 create_dir(const char *dir)
 {
@@ -481,7 +460,7 @@ create_dir(const char *dir)
        return 0;
 }
 
-/* Create directories leading to path. Returns 0 on success, otherwise -1. */
+// Create directories leading to path. Returns 0 on success, otherwise -1.
 int
 create_parent_dirs(const char *path)
 {
@@ -500,15 +479,14 @@ create_parent_dirs(const char *path)
                res = create_parent_dirs(parent);
                if (res == 0) {
                        res = mkdir(parent, 0777);
-                       /* Have to handle the condition of the directory already existing because
-                        * the file system could have changed in between calling stat and
-                        * actually creating the directory. This can happen when there are
-                        * multiple instances of ccache running and trying to create the same
-                        * directory chain, which usually is the case when the cache root does
-                        * not initially exist. As long as one of the processes creates the
-                        * directories then our condition is satisfied and we avoid a race
-                        * condition.
-                        */
+                       // Have to handle the condition of the directory already existing because
+                       // the file system could have changed in between calling stat and
+                       // actually creating the directory. This can happen when there are
+                       // multiple instances of ccache running and trying to create the same
+                       // directory chain, which usually is the case when the cache root does
+                       // not initially exist. As long as one of the processes creates the
+                       // directories then our condition is satisfied and we avoid a race
+                       // condition.
                        if (res != 0 && errno == EEXIST) {
                                res = 0;
                        }
@@ -520,9 +498,7 @@ create_parent_dirs(const char *path)
        return res;
 }
 
-/*
- * Return a static string with the current hostname.
- */
+// Return a static string with the current hostname.
 const char *
 get_hostname(void)
 {
@@ -550,13 +526,13 @@ get_hostname(void)
 
        err = WSAStartup(wVersionRequested, &wsaData);
        if (err != 0) {
-               /* Tell the user that we could not find a usable Winsock DLL. */
+               // Tell the user that we could not find a usable Winsock DLL.
                cc_log("WSAStartup failed with error: %d", err);
                return hostname;
        }
 
        if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) {
-               /* Tell the user that we could not find a usable WinSock DLL. */
+               // Tell the user that we could not find a usable WinSock DLL.
                cc_log("Could not find a usable version of Winsock.dll");
                WSACleanup();
                return hostname;
@@ -597,10 +573,8 @@ get_hostname(void)
        return hostname;
 }
 
-/*
- * Return a string to be passed to mkstemp to create a temporary file. Also
- * tries to cope with NFS by adding the local hostname.
- */
+// 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)
 {
@@ -613,10 +587,8 @@ tmp_string(void)
        return ret;
 }
 
-/*
- * Return the hash result as a hex string. Size -1 means don't include size
- * suffix. Caller frees.
- */
+// Return the hash result as a hex string. Size -1 means don't include size
+// suffix. Caller frees.
 char *
 format_hash_as_string(const unsigned char *hash, int size)
 {
@@ -672,7 +644,7 @@ error:
        return 1;
 }
 
-/* Construct a string according to a format. Caller frees. */
+// Construct a string according to a format. Caller frees.
 char *
 format(const char *format, ...)
 {
@@ -691,7 +663,7 @@ format(const char *format, ...)
        return ptr;
 }
 
-/* This is like strdup() but dies if the malloc fails. */
+// This is like strdup() but dies if the malloc fails.
 char *
 x_strdup(const char *s)
 {
@@ -703,7 +675,7 @@ x_strdup(const char *s)
        return ret;
 }
 
-/* This is like strndup() but dies if the malloc fails. */
+// This is like strndup() but dies if the malloc fails.
 char *
 x_strndup(const char *s, size_t n)
 {
@@ -732,16 +704,14 @@ x_strndup(const char *s, size_t n)
        return ret;
 }
 
-/* This is like malloc() but dies if the malloc fails. */
+// This is like malloc() but dies if the malloc fails.
 void *
 x_malloc(size_t size)
 {
        void *ret;
        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.
-                */
+               // 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;
        }
        ret = malloc(size);
@@ -751,16 +721,14 @@ x_malloc(size_t size)
        return ret;
 }
 
-/* This is like calloc() but dies if the allocation fails. */
+// This is like calloc() but dies if the allocation fails.
 void *
 x_calloc(size_t nmemb, size_t size)
 {
        void *ret;
        if (nmemb * size == 0) {
-               /*
-                * calloc() may return NULL if nmemb or size is 0, so always do this to
-                * make sure that the code handles it regardless of platform.
-                */
+               // calloc() may return NULL if nmemb or size is 0, so always do this to
+               // make sure that the code handles it regardless of platform.
                return NULL;
        }
        ret = calloc(nmemb, size);
@@ -770,7 +738,7 @@ x_calloc(size_t nmemb, size_t size)
        return ret;
 }
 
-/* This is like realloc() but dies if the malloc fails. */
+// This is like realloc() but dies if the malloc fails.
 void *
 x_realloc(void *ptr, size_t size)
 {
@@ -785,17 +753,17 @@ x_realloc(void *ptr, size_t size)
        return p2;
 }
 
-/* This is like unsetenv. */
+// This is like unsetenv.
 void x_unsetenv(const char *name)
 {
 #ifdef HAVE_UNSETENV
        unsetenv(name);
 #else
-       putenv(x_strdup(name)); /* Leak to environment. */
+       putenv(x_strdup(name)); // Leak to environment.
 #endif
 }
 
-/* Like fstat() but also call cc_log on failure. */
+// Like fstat() but also call cc_log on failure.
 int
 x_fstat(int fd, struct stat *buf)
 {
@@ -806,7 +774,7 @@ x_fstat(int fd, struct stat *buf)
        return result;
 }
 
-/* Like lstat() but also call cc_log on failure. */
+// Like lstat() but also call cc_log on failure.
 int
 x_lstat(const char *pathname, struct stat *buf)
 {
@@ -817,7 +785,7 @@ x_lstat(const char *pathname, struct stat *buf)
        return result;
 }
 
-/* Like stat() but also call cc_log on failure. */
+// Like stat() but also call cc_log on failure.
 int
 x_stat(const char *pathname, struct stat *buf)
 {
@@ -828,10 +796,8 @@ x_stat(const char *pathname, struct stat *buf)
        return result;
 }
 
-/*
- * Construct a string according to the format and store it in *ptr. The
- * original *ptr is then freed.
- */
+// Construct a string according to the format and store it in *ptr. The
+// original *ptr is then freed.
 void
 reformat(char **ptr, const char *format, ...)
 {
@@ -853,9 +819,7 @@ reformat(char **ptr, const char *format, ...)
        }
 }
 
-/*
- * Recursive directory traversal. fn() is called on all entries in the tree.
- */
+// Recursive directory traversal. fn() is called on all entries in the tree.
 void
 traverse(const char *dir, void (*fn)(const char *, struct stat *))
 {
@@ -903,7 +867,7 @@ traverse(const char *dir, void (*fn)(const char *, struct stat *))
 }
 
 
-/* return the base name of a file - caller frees */
+// Return the base name of a file - caller frees.
 char *
 basename(const char *path)
 {
@@ -922,7 +886,7 @@ basename(const char *path)
        return x_strdup(path);
 }
 
-/* return the dir name of a file - caller frees */
+// Return the dir name of a file - caller frees.
 char *
 dirname(const char *path)
 {
@@ -950,11 +914,9 @@ dirname(const char *path)
        return s;
 }
 
-/*
- * Return the file extension (including the dot) of a path as a pointer into
- * path. If path has no file extension, the empty string and the end of path is
- * returned.
- */
+// Return the file extension (including the dot) of a path as a pointer into
+// path. If path has no file extension, the empty string and the end of path is
+// returned.
 const char *
 get_extension(const char *path)
 {
@@ -972,17 +934,15 @@ get_extension(const char *path)
        return &path[len];
 }
 
-/*
- * Return a string containing the given path without the filename extension.
- * Caller frees.
- */
+// Return a string containing the given path without the filename extension.
+// Caller frees.
 char *
 remove_extension(const char *path)
 {
        return x_strndup(path, strlen(path) - strlen(get_extension(path)));
 }
 
-/* return size on disk of a file */
+// Return size on disk of a file.
 size_t
 file_size(struct stat *st)
 {
@@ -991,14 +951,14 @@ file_size(struct stat *st)
 #else
        size_t size = st->st_blocks * 512;
        if ((size_t)st->st_size > size) {
-               /* probably a broken stat() call ... */
+               // Probably a broken stat() call...
                size = (st->st_size + 1023) & ~1023;
        }
        return size;
 #endif
 }
 
-/* Format a size as a human-readable string. Caller frees. */
+// Format a size as a human-readable string. Caller frees.
 char *
 format_human_readable_size(uint64_t v)
 {
@@ -1013,7 +973,7 @@ format_human_readable_size(uint64_t v)
        return s;
 }
 
-/* Format a size as a parsable string. Caller frees. */
+// Format a size as a parsable string. Caller frees.
 char *
 format_parsable_size_with_suffix(uint64_t size)
 {
@@ -1030,11 +990,9 @@ format_parsable_size_with_suffix(uint64_t size)
        return s;
 }
 
-/*
- * Parse a "size value", i.e. a string that can end in k, M, G, T (10-based
- * suffixes) or Ki, Mi, Gi, Ti (2-based suffixes). For backward compatibility,
- * K is also recognized as a synonym of k.
- */
+// Parse a "size value", i.e. a string that can end in k, M, G, T (10-based
+// suffixes) or Ki, Mi, Gi, Ti (2-based suffixes). For backward compatibility,
+// K is also recognized as a synonym of k.
 bool
 parse_size_with_suffix(const char *str, uint64_t *size)
 {
@@ -1073,7 +1031,7 @@ parse_size_with_suffix(const char *str, uint64_t *size)
                        return false;
                }
        } else {
-               /* Default suffix: G. */
+               // Default suffix: G.
                x *= 1000 * 1000 * 1000;
        }
        *size = x;
@@ -1121,10 +1079,10 @@ static BOOL GetFileNameFromHandle(HANDLE hFile, TCHAR *pszFilename,
                                TCHAR *p = szTemp;
 
                                do {
-                                       // Copy the drive letter to the template string
+                                       // Copy the drive letter to the template string.
                                        *szDrive = *p;
 
-                                       // Look up each device name
+                                       // Look up each device name.
                                        if (QueryDosDevice(szDrive, szName, MAX_PATH)) {
                                                size_t uNameLen = _tcslen(szName);
 
@@ -1132,8 +1090,8 @@ static BOOL GetFileNameFromHandle(HANDLE hFile, TCHAR *pszFilename,
                                                        bFound = _tcsnicmp(pszFilename, szName, uNameLen) == 0
                                                                 && *(pszFilename + uNameLen) == _T('\\');
                                                        if (bFound) {
-                                                               // Reconstruct pszFilename using szTempFile
-                                                               // Replace device path with DOS path
+                                                               // Reconstruct pszFilename using szTempFile and replace device
+                                                               // path with DOS path.
                                                                TCHAR szTempFile[MAX_PATH];
                                                                _sntprintf(szTempFile,
                                                                           MAX_PATH - 1,
@@ -1149,7 +1107,7 @@ static BOOL GetFileNameFromHandle(HANDLE hFile, TCHAR *pszFilename,
                                        while (*p++) {
                                                // Do nothing.
                                        }
-                               } while (!bFound && *p); // end of string
+                               } while (!bFound && *p); // End of string.
                        }
                }
                bSuccess = TRUE;
@@ -1161,8 +1119,8 @@ static BOOL GetFileNameFromHandle(HANDLE hFile, TCHAR *pszFilename,
 }
 #endif
 
-/* A sane realpath() function, trying to cope with stupid path limits and a
- * broken API. Caller frees. */
+// A sane realpath() function, trying to cope with stupid path limits and a
+// broken API. Caller frees.
 char *
 x_realpath(const char *path)
 {
@@ -1178,7 +1136,7 @@ x_realpath(const char *path)
        p = realpath(path, ret);
 #elif defined(_WIN32)
        if (path[0] == '/') {
-               path++;  /* skip leading slash */
+               path++;  // Skip leading slash.
        }
        path_handle = CreateFile(
          path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
@@ -1190,14 +1148,14 @@ x_realpath(const char *path)
                GetFileNameFromHandle(path_handle, ret, maxlen);
 #endif
                CloseHandle(path_handle);
-               p = ret + 4; /* strip \\?\ from the file name */
+               p = ret + 4; // Strip \\?\ from the file name.
        } else {
                snprintf(ret, maxlen, "%s", path);
                p = ret;
        }
 #else
-       /* yes, there are such systems. This replacement relies on
-          the fact that when we call x_realpath we only care about symlinks */
+       // Yes, there are such systems. This replacement relies on the fact that when
+       // we call x_realpath we only care about symlinks.
        {
                int len = readlink(path, ret, maxlen-1);
                if (len == -1) {
@@ -1217,7 +1175,7 @@ x_realpath(const char *path)
        return NULL;
 }
 
-/* a getcwd that will returns an allocated buffer */
+// A getcwd that will returns an allocated buffer.
 char *
 gnu_getcwd(void)
 {
@@ -1238,7 +1196,7 @@ gnu_getcwd(void)
 }
 
 #ifndef HAVE_STRTOK_R
-/* strtok_r replacement */
+// strtok_r replacement.
 char *
 strtok_r(char *str, const char *delim, char **saveptr)
 {
@@ -1252,7 +1210,7 @@ strtok_r(char *str, const char *delim, char **saveptr)
        if (ret) {
                char *save = ret;
                while (*save++) {
-                       /* Do nothing. */
+                       // Do nothing.
                }
                if ((len + 1) == (intptr_t) (save - str)) {
                        save--;
@@ -1263,10 +1221,8 @@ strtok_r(char *str, const char *delim, char **saveptr)
 }
 #endif
 
-/*
- * Create an empty temporary file. *fname will be reallocated and set to the
- * resulting filename. Returns an open file descriptor to the file.
- */
+// Create an empty temporary file. *fname will be reallocated and set to the
+// resulting filename. Returns an open file descriptor to the file.
 int
 create_tmp_fd(char **fname)
 {
@@ -1294,10 +1250,8 @@ create_tmp_fd(char **fname)
        return fd;
 }
 
-/*
- * Create an empty temporary file. *fname will be reallocated and set to the
- * resulting filename. Returns an open FILE*.
- */
+// Create an empty temporary file. *fname will be reallocated and set to the
+// resulting filename. Returns an open FILE*.
 FILE *
 create_tmp_file(char **fname, const char *mode)
 {
@@ -1308,9 +1262,7 @@ create_tmp_file(char **fname, const char *mode)
        return file;
 }
 
-/*
- * Return current user's home directory, or NULL if it can't be determined.
- */
+// Return current user's home directory, or NULL if it can't be determined.
 const char *
 get_home_directory(void)
 {
@@ -1335,10 +1287,8 @@ get_home_directory(void)
        return NULL;
 }
 
-/*
- * Get the current directory by reading $PWD. If $PWD isn't sane, gnu_getcwd()
- * is used. Caller frees.
- */
+// Get the current directory by reading $PWD. If $PWD isn't sane, gnu_getcwd()
+// is used. Caller frees.
 char *
 get_cwd(void)
 {
@@ -1369,9 +1319,7 @@ get_cwd(void)
        }
 }
 
-/*
- * Check whether s1 and s2 have the same executable name.
- */
+// Check whether s1 and s2 have the same executable name.
 bool
 same_executable_name(const char *s1, const char *s2)
 {
@@ -1388,10 +1336,8 @@ same_executable_name(const char *s1, const char *s2)
 #endif
 }
 
-/*
- * Compute the length of the longest directory path that is common to two
- * paths. s1 is assumed to be the path to a directory.
- */
+// Compute the length of the longest directory path that is common to two
+// paths. s1 is assumed to be the path to a directory.
 size_t
 common_dir_prefix_length(const char *s1, const char *s2)
 {
@@ -1407,17 +1353,15 @@ common_dir_prefix_length(const char *s1, const char *s2)
                p2--;
        }
        if (!*p1 && !*p2 && p2 == s2 + 1) {
-               /* Special case for s1 and s2 both being "/". */
+               // Special case for s1 and s2 both being "/".
                return 0;
        }
        return p1 - s1;
 }
 
-/*
- * Compute a relative path from from (an absolute path to a directory) to to (a
- * path). Assumes that both from and to are well-formed and canonical. Caller
- * frees.
- */
+// Compute a relative path from from (an absolute path to a directory) to to (a
+// path). Assumes that both from and to are well-formed and canonical. Caller
+// frees.
 char *
 get_relative_path(const char *from, const char *to)
 {
@@ -1433,15 +1377,15 @@ get_relative_path(const char *from, const char *to)
        }
 
 #ifdef _WIN32
-       // Paths can be escaped by a slash for use with -isystem
+       // Paths can be escaped by a slash for use with -isystem.
        if (from[0] == '/') {
                from++;
        }
        if (to[0] == '/') {
                to++;
        }
-       // Both paths are absolute, drop the drive letters
-       assert(from[0] == to[0]); // Assume the same drive letter
+       // Both paths are absolute, drop the drive letters.
+       assert(from[0] == to[0]); // Assume the same drive letter.
        from += 2;
        to += 2;
 #endif
@@ -1471,9 +1415,7 @@ get_relative_path(const char *from, const char *to)
        return result;
 }
 
-/*
- * Return whether path is absolute.
- */
+// Return whether path is absolute.
 bool
 is_absolute_path(const char *path)
 {
@@ -1484,9 +1426,7 @@ is_absolute_path(const char *path)
 #endif
 }
 
-/*
- * Return whether the argument is a full path.
- */
+// Return whether the argument is a full path.
 bool
 is_full_path(const char *path)
 {
@@ -1512,10 +1452,8 @@ bool is_symlink(const char *path)
 #endif
 }
 
-/*
- * Update the modification time of a file in the cache to save it from LRU
- * cleanup.
- */
+// Update the modification time of a file in the cache to save it from LRU
+// cleanup.
 void
 update_mtime(const char *path)
 {
@@ -1526,10 +1464,8 @@ update_mtime(const char *path)
 #endif
 }
 
-/*
- * If exit() already has been called, call _exit(), otherwise exit(). This is
- * used to avoid calling exit() inside an atexit handler.
- */
+// If exit() already has been called, call _exit(), otherwise exit(). This is
+// used to avoid calling exit() inside an atexit handler.
 void
 x_exit(int status)
 {
@@ -1542,18 +1478,16 @@ x_exit(int status)
        }
 }
 
-/*
- * Rename oldpath to newpath (deleting newpath).
- */
+// Rename oldpath to newpath (deleting newpath).
 int
 x_rename(const char *oldpath, const char *newpath)
 {
 #ifndef _WIN32
        return rename(oldpath, newpath);
 #else
-       /* Windows' rename() refuses to overwrite an existing file. */
-       unlink(newpath);  /* not x_unlink, as x_unlink calls x_rename */
-       /* If the function succeeds, the return value is nonzero. */
+       // Windows' rename() refuses to overwrite an existing file.
+       unlink(newpath);  // Not x_unlink, as x_unlink calls x_rename.
+       // If the function succeeds, the return value is nonzero.
        if (MoveFileA(oldpath, newpath) == 0) {
                LPVOID lpMsgBuf;
                LPVOID lpDisplayBuf;
@@ -1586,10 +1520,8 @@ x_rename(const char *oldpath, const char *newpath)
 #endif
 }
 
-/*
- * Remove path, NFS hazardous. Use only for temporary files that will not exist
- * on other systems. That is, the path should include tmp_string().
- */
+// Remove path, NFS hazardous. Use only for temporary files that will not exist
+// on other systems. That is, the path should include tmp_string().
 int
 tmp_unlink(const char *path)
 {
@@ -1602,17 +1534,13 @@ tmp_unlink(const char *path)
        return rc;
 }
 
-/*
- * Remove path, NFS safe.
- */
+// Remove path, NFS safe.
 int
 x_unlink(const char *path)
 {
-       /*
-        * If path is on an NFS share, unlink isn't atomic, so we rename to a temp
-        * file. We don't care if the temp file is trashed, so it's always safe to
-        * unlink it first.
-        */
+       // If path is on an NFS share, unlink isn't atomic, so we rename to a temp
+       // file. We don't care if the temp file is trashed, so it's always safe to
+       // unlink it first.
        char *tmp_name = format("%s.rm.%s", path, tmp_string());
        int result = 0;
        int saved_errno = 0;
@@ -1623,7 +1551,7 @@ x_unlink(const char *path)
                goto out;
        }
        if (unlink(tmp_name) == -1) {
-               /* If it was released in a race, that's OK. */
+               // If it was released in a race, that's OK.
                if (errno != ENOENT && errno != ESTALE) {
                        result = -1;
                        saved_errno = errno;
@@ -1639,7 +1567,7 @@ out:
 }
 
 #ifndef _WIN32
-/* Like readlink() but returns the string or NULL on failure. Caller frees. */
+// Like readlink() but returns the string or NULL on failure. Caller frees.
 char *
 x_readlink(const char *path)
 {
@@ -1658,10 +1586,8 @@ x_readlink(const char *path)
 }
 #endif
 
-/*
- * Reads the content of a file. Size hint 0 means no hint. Returns true on
- * success, otherwise false.
- */
+// Reads the content of a file. Size hint 0 means no hint. Returns true on
+// success, otherwise false.
 bool
 read_file(const char *path, size_t size_hint, char **data, size_t *size)
 {
@@ -1707,10 +1633,8 @@ read_file(const char *path, size_t size_hint, char **data, size_t *size)
        return true;
 }
 
-/*
- * Return the content (with NUL termination) of a text file, or NULL on error.
- * Caller frees. Size hint 0 means no hint.
- */
+// Return the content (with NUL termination) of a text file, or NULL on error.
+// Caller frees. Size hint 0 means no hint.
 char *
 read_text_file(const char *path, size_t size_hint)
 {
@@ -1754,7 +1678,7 @@ expand_variable(const char **str, char **result, char **errmsg)
        }
 
        if (q == p) {
-               /* Special case: don't consider a single $ the start of a variable. */
+               // Special case: don't consider a single $ the start of a variable.
                reformat(result, "%s$", *result);
                return true;
        }
@@ -1775,17 +1699,15 @@ expand_variable(const char **str, char **result, char **errmsg)
        return true;
 }
 
-/*
- * Substitute all instances of $VAR or ${VAR}, where VAR is an environment
- * variable, in a string. Caller frees. If one of the environment variables
- * doesn't exist, NULL will be returned and *errmsg will be an appropriate
- * error message (caller frees).
- */
+// Substitute all instances of $VAR or ${VAR}, where VAR is an environment
+// variable, in a string. Caller frees. If one of the environment variables
+// doesn't exist, NULL will be returned and *errmsg will be an appropriate
+// error message (caller frees).
 char *
 subst_env_in_string(const char *str, char **errmsg)
 {
-       const char *p; /* Interval start. */
-       const char *q; /* Interval end. */
+       const char *p; // Interval start.
+       const char *q; // Interval end.
        char *result;
 
        assert(errmsg);