From: Joel Rosdahl Date: Wed, 2 Jan 2019 21:12:27 +0000 (+0100) Subject: Improve code style and comments X-Git-Tag: v3.6~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d39fe87bcbb9ef61fbcf018b949de70f943eada6;p=thirdparty%2Fccache.git Improve code style and comments --- diff --git a/src/ccache.c b/src/ccache.c index e7d5d2973..45321d40c 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -1100,13 +1100,14 @@ out: free(tmp_file); } -// extract the used includes from the dependency file -// note we cannot distinguish system headers from other includes here +// Extract the used includes from the dependency file. Note that we cannot +// distinguish system headers from other includes here. static struct file_hash * -object_hash_from_depfile(const char *depfile, struct hash *hash) { +object_hash_from_depfile(const char *depfile, struct hash *hash) +{ FILE *f = fopen(depfile, "r"); if (!f) { - cc_log("Cannot open dependency file: %s (%s)", depfile, strerror(errno)); + cc_log("Cannot open dependency file %s: %s", depfile, strerror(errno)); return NULL; } @@ -1367,9 +1368,8 @@ to_cache(struct args *args, struct hash *depend_mode_hash) tmp_stderr = format("%s/tmp.stderr", temp_dir()); tmp_stderr_fd = create_tmp_fd(&tmp_stderr); - // Use the original arguments (including deps) in depend mode. - // Similar to failed(); - // FIXME: on error we probably do not want to fall back to failed() anymore + // Use the original arguments (including dependency options) in depend + // mode. assert(orig_args); struct args *depend_mode_args = args_copy(orig_args); args_strip(depend_mode_args, "--ccache-"); @@ -1462,12 +1462,15 @@ to_cache(struct args *args, struct hash *depend_mode_hash) } if (conf->depend_mode) { - struct file_hash *object_hash = object_hash_from_depfile(output_dep, depend_mode_hash); - if (!object_hash) + struct file_hash *object_hash = + object_hash_from_depfile(output_dep, depend_mode_hash); + if (!object_hash) { failed(); + } update_cached_result_globals(object_hash); - // in depend_mode it does not make sense to update an existing manifest file + // It does not make sense to update an existing manifest file in the depend + // mode. x_unlink(manifest_path); } @@ -3556,7 +3559,8 @@ ccache(int argc, char *argv[]) failed(); } - if (conf->depend_mode && (!generating_dependencies || !conf->run_second_cpp)) { + if (conf->depend_mode + && (!generating_dependencies || !conf->run_second_cpp)) { cc_log("Disabling depend mode"); conf->depend_mode = false; } @@ -3630,12 +3634,13 @@ ccache(int argc, char *argv[]) } if (!conf->depend_mode) { - // Find the hash using the preprocessed output. Also updates included_files. + // Find the hash using the preprocessed output. Also updates + // included_files. struct hash *cpp_hash = hash_copy(common_hash); init_hash_debug( - cpp_hash, output_obj, 'p', "PREPROCESSOR MODE", debug_text_file); + cpp_hash, output_obj, 'p', "PREPROCESSOR MODE", debug_text_file); - object_hash = calculate_object_hash(preprocessor_args, cpp_hash, 0); + object_hash = calculate_object_hash(preprocessor_args, cpp_hash, 0); if (!object_hash) { fatal("internal error: object hash from cpp returned NULL"); } @@ -3643,8 +3648,8 @@ 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 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). @@ -3652,9 +3657,9 @@ ccache(int argc, char *argv[]) // 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 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"); diff --git a/test/suites/depend.bash b/test/suites/depend.bash index 10b0f11e1..f59b36c4c 100644 --- a/test/suites/depend.bash +++ b/test/suites/depend.bash @@ -92,5 +92,5 @@ EOF expect_stat 'cache miss' 1 expect_file_content stderr-mf.txt "`cat stderr-baseline.txt`" - # FIXME: add more test cases (see direct.bash for inspiration) + # TODO: Add more test cases (see direct.bash for inspiration) } diff --git a/unittest/test_conf.c b/unittest/test_conf.c index 36b0e723a..61f381667 100644 --- a/unittest/test_conf.c +++ b/unittest/test_conf.c @@ -112,7 +112,7 @@ TEST(conf_read_valid_config) "compression=true\n" "compression_level= 2\n" "cpp_extension = .foo\n" - "depend_mode = true\n" + "depend_mode = true\n" "direct_mode = false\n" "disable = true\n" "extra_files_to_hash = a:b c:$USER\n"