]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Minor cleanup
authorJoel Rosdahl <joel@rosdahl.net>
Mon, 13 Feb 2012 18:56:19 +0000 (19:56 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Mon, 13 Feb 2012 18:56:19 +0000 (19:56 +0100)
ccache.c
conf.c

index 7b93f5c2aa517630f50a3e7817f7d12827dcc193..918ea1cbe446974d4df3d29cd1d3b475122e2a0e 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -192,34 +192,37 @@ static const char HASH_PREFIX[] = "3";
 static void
 add_prefix(struct args *orig_args)
 {
-       if (!str_eq(conf->prefix_command, "")) {
-               char *e;
-               char *tok, *saveptr = NULL;
-               struct args *prefix = args_init(0, NULL);
-               int i;
-
-               e = x_strdup(conf->prefix_command);
-               for (tok = strtok_r(e, " ", &saveptr);
-                    tok;
-                    tok = strtok_r(NULL, " ", &saveptr)) {
-                       char *p;
+       char *e;
+       char *tok, *saveptr = NULL;
+       struct args *prefix;
+       int i;
 
-                       p = find_executable(tok, MYNAME);
-                       if (!p) {
-                               fatal("%s: %s", tok, strerror(errno));
-                       }
+       if (str_eq(conf->prefix_command, "")) {
+               return;
+       }
 
-                       args_add(prefix, p);
-                       free(p);
-               }
-               free(e);
+       prefix = args_init(0, NULL);
+       e = x_strdup(conf->prefix_command);
+       for (tok = strtok_r(e, " ", &saveptr);
+            tok;
+            tok = strtok_r(NULL, " ", &saveptr)) {
+               char *p;
 
-               cc_log("Using command-line prefix %s", conf->prefix_command);
-               for (i = prefix->argc; i != 0; i--) {
-                       args_add_prefix(orig_args, prefix->argv[i-1]);
+               p = find_executable(tok, MYNAME);
+               if (!p) {
+                       fatal("%s: %s", tok, strerror(errno));
                }
-               args_free(prefix);
+
+               args_add(prefix, p);
+               free(p);
        }
+       free(e);
+
+       cc_log("Using command-line prefix %s", conf->prefix_command);
+       for (i = prefix->argc; i != 0; i--) {
+               args_add_prefix(orig_args, prefix->argv[i-1]);
+       }
+       args_free(prefix);
 }
 
 /* Something went badly wrong - just execute the real compiler. */
@@ -228,10 +231,7 @@ failed(void)
 {
        assert(orig_args);
 
-       /* strip any local args */
        args_strip(orig_args, "--ccache-");
-
-       /* add prefix from CCACHE_PREFIX */
        add_prefix(orig_args);
 
        cc_log("Failed; falling back to running the real compiler");
@@ -2235,7 +2235,6 @@ ccache(int argc, char *argv[])
                failed();
        }
 
-       /* add prefix from CCACHE_PREFIX */
        add_prefix(compiler_args);
 
        /* run real compiler, sending output to cache */
diff --git a/conf.c b/conf.c
index 7b1cefdb9b55cd19e36951436094fbb25dbae319..de549e1500345270d0066cde968201c0f1667280 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Joel Rosdahl
+ * Copyright (C) 2011-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
@@ -516,7 +516,8 @@ conf_print_items(struct conf *conf,
        printer(s, conf->item_origins[find_conf("cache_dir")->number], context);
 
        reformat(&s, "cache_dir_levels = %u", conf->cache_dir_levels);
-       printer(s, conf->item_origins[find_conf("cache_dir_levels")->number], context);
+       printer(s, conf->item_origins[find_conf("cache_dir_levels")->number],
+               context);
 
        reformat(&s, "compiler = %s", conf->compiler);
        printer(s, conf->item_origins[find_conf("compiler")->number], context);
@@ -537,7 +538,8 @@ conf_print_items(struct conf *conf,
        printer(s, conf->item_origins[find_conf("disable")->number], context);
 
        reformat(&s, "extra_files_to_hash = %s", conf->extra_files_to_hash);
-       printer(s, conf->item_origins[find_conf("extra_files_to_hash")->number], context);
+       printer(s, conf->item_origins[find_conf("extra_files_to_hash")->number],
+               context);
 
        reformat(&s, "hard_link = %s", conf->hard_link ? "true" : "false");
        printer(s, conf->item_origins[find_conf("hard_link")->number], context);