]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Treat configuration errors as warnings instead of fatal errors
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 8 Feb 2017 20:42:21 +0000 (21:42 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 8 Feb 2017 20:42:21 +0000 (21:42 +0100)
NEWS.txt
ccache.c
ccache.h
util.c

index 49ac7609f4c9f3a38bf6411e201d883a2824867c..c4994afc43ce35ff2963742bc4b76457594746ed 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -12,6 +12,8 @@ New features and improvements
 
 - Added support for caching `.su` files generated by GCC flag `-fstack-usage`.
 
+- Configuration errors are now treated as warnings instead of fatal errors.
+
 
 ccache 3.3.3
 ------------
index 44378cca3b492df3a876b41cc4297b1bed66b475..84e27490c77e9e75405fb1ae74b4fa4cf56f05cf 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -3105,7 +3105,7 @@ initialize(void)
                secondary_config_path = format("%s/ccache.conf", TO_STRING(SYSCONFDIR));
                if (!conf_read(conf, secondary_config_path, &errmsg)) {
                        if (stat(secondary_config_path, &st) == 0) {
-                               fatal("%s", errmsg);
+                               warn("%s", errmsg);
                        }
                        // Missing config file in SYSCONFDIR is OK.
                        free(errmsg);
@@ -3128,13 +3128,13 @@ initialize(void)
        bool should_create_initial_config = false;
        if (!conf_read(conf, primary_config_path, &errmsg)) {
                if (stat(primary_config_path, &st) == 0) {
-                       fatal("%s", errmsg);
+                       warn("%s", errmsg);
                }
                should_create_initial_config = true;
        }
 
        if (!conf_update_from_environment(conf, &errmsg)) {
-               fatal("%s", errmsg);
+               warn("%s", errmsg);
        }
 
        if (conf->disable) {
index cf7d0ff7af0a3fe8ab47e0fe766358f545a5ca8b..d8030966a59b8cecf29e8f5656593b74069bd72e 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -126,6 +126,7 @@ void cc_log(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
 void cc_bulklog(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
 void cc_log_argv(const char *prefix, char **argv);
 void fatal(const char *format, ...) ATTR_FORMAT(printf, 1, 2) ATTR_NORETURN;
+void warn(const char *format, ...) ATTR_FORMAT(printf, 1, 2);
 
 void copy_fd(int fd_in, int fd_out);
 int copy_file(const char *src, const char *dest, int compress_level);
diff --git a/util.c b/util.c
index 6122c84365e8a896769d032592ba567f3bc21616..e3889b65361d2e6211049647e60758e8d9fe026a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,5 +1,5 @@
 // Copyright (C) 2002 Andrew Tridgell
-// Copyright (C) 2009-2016 Joel Rosdahl
+// Copyright (C) 2009-2017 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
@@ -187,6 +187,19 @@ fatal(const char *format, ...)
        x_exit(1);
 }
 
+void
+warn(const char *format, ...)
+{
+       va_list ap;
+       va_start(ap, format);
+       char msg[1000];
+       vsnprintf(msg, sizeof(msg), format, ap);
+       va_end(ap);
+
+       cc_log("WARNING: %s", msg);
+       fprintf(stderr, "ccache: warning: %s\n", msg);
+}
+
 // 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)