]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Minor cleanup
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 21 Jul 2016 20:17:23 +0000 (22:17 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 21 Jul 2016 20:17:41 +0000 (22:17 +0200)
ccache.c
test.sh

index 29f1c73e5b81ec680a3a235e73fcd3216f9fc088..0f9431d1e70b911da7dd8bb42bd53dac5c75a734 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -106,10 +106,10 @@ static char *output_dia = NULL;
  *  up). Contains pathname if not NULL. */
 static char *output_dwo = NULL;
 
-/* Vector for storing -arch options */
-#define MAX_ARCH_ARGS (10)
+/* Array for storing -arch options. */
+#define MAX_ARCH_ARGS 10
 static size_t arch_args_size = 0;
-static chararch_args[MAX_ARCH_ARGS] = {NULL};
+static char *arch_args[MAX_ARCH_ARGS] = {NULL};
 
 /*
  * Name (represented as a struct file_hash) of the file containing the cached
@@ -1940,12 +1940,13 @@ calculate_object_hash(struct args *args, struct mdfour *hash, int direct_mode)
                        object_hash = get_object_name_from_cpp(args, hash);
                        cc_log("Got object file hash from preprocessor");
                } else {
-                       size_t i = 0;
+                       size_t i;
                        args_add(args, "-arch");
-                       for(i = 0; i < arch_args_size; ++i) {
+                       for (i = 0; i < arch_args_size; ++i) {
                                args_add(args, arch_args[i]);
                                object_hash = get_object_name_from_cpp(args, hash);
-                               cc_log("Got object file hash from preprocessor with -arch %s", arch_args[i]);
+                               cc_log("Got object file hash from preprocessor with -arch %s",
+                                      arch_args[i]);
                                if (i != arch_args_size - 1) {
                                        free(object_hash);
                                }
@@ -2207,6 +2208,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                 struct args **compiler_args)
 {
        int i;
+       size_t j;
        bool found_c_opt = false;
        bool found_S_opt = false;
        bool found_pch = false;
@@ -2354,7 +2356,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                        }
                }
 
-               /* -Xarch_* options are too hard */
+               /* -Xarch_* options are too hard. */
                if (str_startswith(argv[i], "-Xarch_")) {
                        cc_log("Unsupported compiler option :%s", argv[i]);
                        stats_update(STATS_UNSUPPORTED);
@@ -2365,15 +2367,18 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                /* Handle -arch options. */
                if (str_eq(argv[i], "-arch")) {
                        if (arch_args_size == MAX_ARCH_ARGS - 1) {
-                               cc_log("Too many -arch compiler options are unsupported");
+                               cc_log("Too many -arch compiler options; ccache supports at most %d",
+                                      MAX_ARCH_ARGS);
                                stats_update(STATS_UNSUPPORTED);
                                result = false;
                                goto out;
-                       } else {
-                               arch_args[arch_args_size++] = x_strdup(argv[++i]); /* it will leak */
-                               if (arch_args_size == 2) {
-                                       conf->run_second_cpp = true;
-                               }
+                       }
+
+                       ++i;
+                       arch_args[arch_args_size] = x_strdup(argv[i]); /* it will leak */
+                       ++arch_args_size;
+                       if (arch_args_size == 2) {
+                               conf->run_second_cpp = true;
                        }
                        continue;
                }
@@ -3108,8 +3113,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                args_add(*compiler_args, "-c");
        }
 
-       size_t j = 0;
-       for(j = 0; j < arch_args_size; ++j) {
+       for (j = 0; j < arch_args_size; ++j) {
                args_add(*compiler_args, "-arch");
                args_add(*compiler_args, arch_args[j]);
        }
@@ -3377,7 +3381,7 @@ ccache(int argc, char *argv[])
        cc_log("Working directory: %s", get_current_working_dir());
 
        if (conf->unify) {
-               cc_log("Direct mode is disabled because unify mode is enabled");
+               cc_log("Direct mode disabled because unify mode is enabled");
                conf->direct_mode = false;
        }
 
diff --git a/test.sh b/test.sh
index 776f9cb82c1c150664f231d49cdf1a1635da71ae..28f1df8192af84f14fdbfb6df8c8a593edbba8db 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -668,7 +668,7 @@ EOF
         checkstat 'cache hit (preprocessed)' 1
         checkstat 'cache miss' 1
     fi
-       
+
     ##################################################################
     # Check that -Wp,-P disables ccache. (-P removes preprocessor information
     # in such a way that the object file from compiling the preprocessed file