]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Remove incorrect preconditions for outputting captured stderr
authorryb <ryb@ableton.com>
Sat, 7 Feb 2015 13:28:48 +0000 (14:28 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 9 Feb 2015 20:32:04 +0000 (21:32 +0100)
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.

ccache.c

index 0b6643bebda694c697ab19dc72e5fb5cb658558d..cd6f11c3581d444a4789aabd6ba6ec6914c1c21f 100644 (file)
--- 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);