From: ryb Date: Sat, 7 Feb 2015 13:28:48 +0000 (+0100) Subject: Remove incorrect preconditions for outputting captured stderr X-Git-Tag: v3.2.2~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6318b2d49b6ef8fe1c3c6ffec95af2c8fec3242a;p=thirdparty%2Fccache.git Remove incorrect preconditions for outputting captured stderr errno is set in an unrelated system call. In my tests involving compiler failures, it is last set to ENOENT in from_cache() when calling stat() for the cached object, accidentally making "errno == ENOENT" true. The condition was no longer necessary as of 18a645451 ("Create destination file and then copy into cache instead of the opposite"), as the temp output file no longer needed to be moved. --- diff --git a/ccache.c b/ccache.c index 0b6643beb..cd6f11c35 100644 --- a/ccache.c +++ b/ccache.c @@ -838,37 +838,36 @@ to_cache(struct args *args) fd = open(tmp_stderr, O_RDONLY | O_BINARY); if (fd != -1) { - if (str_eq(output_obj, "/dev/null") || errno == ENOENT) { - /* we can use a quick method of getting the failed output */ - copy_fd(fd, 2); - close(fd); - tmp_unlink(tmp_stderr); - - if (output_dia) { - int ret; - x_unlink(output_dia); - /* only make a hardlink if the cache file is uncompressed */ - ret = move_file(tmp_dia, output_dia, 0); - - if (ret == -1) { - if (errno == ENOENT) { - /* Someone removed the file just before we began copying? */ - cc_log("Diagnostic file %s just disappeared", output_dia); - stats_update(STATS_MISSING); - } else { - cc_log("Failed to move %s to %s: %s", - tmp_dia, output_dia, strerror(errno)); - stats_update(STATS_ERROR); - failed(); - } - x_unlink(tmp_dia); + /* we can output stderr immediately instead of re-running the + * compiler */ + copy_fd(fd, 2); + close(fd); + tmp_unlink(tmp_stderr); + + if (output_dia) { + int ret; + x_unlink(output_dia); + /* only make a hardlink if the cache file is uncompressed */ + ret = move_file(tmp_dia, output_dia, 0); + + if (ret == -1) { + if (errno == ENOENT) { + /* Someone removed the file just before we began copying? */ + cc_log("Diagnostic file %s just disappeared", output_dia); + stats_update(STATS_MISSING); } else { - cc_log("Created %s from %s", output_dia, tmp_dia); + cc_log("Failed to move %s to %s: %s", + tmp_dia, output_dia, strerror(errno)); + stats_update(STATS_ERROR); + failed(); } + x_unlink(tmp_dia); + } else { + cc_log("Created %s from %s", output_dia, tmp_dia); } - - exit(status); } + + exit(status); } tmp_unlink(tmp_stderr);