]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/ccanlint.c
ccanlint: remove wart from info options.
[ccan] / tools / ccanlint / ccanlint.c
index b35f11a7b8947d3cd79a9a9b7c925e6cc3b8dd71..fd7e0c719001af2d0a58f26f04e3fa0d19465989 100644 (file)
@@ -41,6 +41,7 @@ TLIST_TYPE(ccanlint, struct ccanlint);
 int verbose = 0;
 static struct tlist_ccanlint tests = TLIST_INIT(tests);
 bool safe_mode = false;
+static bool targeting = false;
 static struct btree *cmdline_exclude;
 static struct btree *info_exclude;
 static unsigned int timeout;
@@ -421,7 +422,7 @@ static void add_options(struct ccanlint *test, char **options,
        memcpy(&test->options[num], options, (num_options + 1)*sizeof(char *));
 }
 
-static void add_info_options(struct ccan_file *info, bool mark_fails)
+void add_info_options(struct ccan_file *info)
 {
        struct doc_section *d;
        unsigned int i;
@@ -456,7 +457,7 @@ static void add_info_options(struct ccan_file *info, bool mark_fails)
 
                        /* Known failure? */
                        if (strcasecmp(words[1], "FAIL") == 0) {
-                               if (mark_fails)
+                               if (!targeting)
                                        btree_insert(info_exclude, words[0]);
                        } else {
                                if (!test->takes_options)
@@ -641,6 +642,8 @@ int main(int argc, char *argv[])
        cmdline_exclude = btree_new(btree_strcmp);
        info_exclude = btree_new(btree_strcmp);
 
+       opt_register_early_noarg("--verbose|-v", opt_inc_intval, &verbose,
+                                "verbose mode (up to -vvvv)");
        opt_register_noarg("-n|--safe-mode", opt_set_bool, &safe_mode,
                         "do not compile anything");
        opt_register_noarg("-l|--list-tests", list_tests, NULL,
@@ -652,8 +655,6 @@ int main(int argc, char *argv[])
                         " (can be used multiple times, or 'all')");
        opt_register_noarg("--summary|-s", opt_set_bool, &summary,
                           "simply give one line summary");
-       opt_register_noarg("--verbose|-v", opt_inc_intval, &verbose,
-                          "verbose mode (up to -vvvv)");
        opt_register_arg("-x|--exclude <testname>", skip_test, NULL, NULL,
                         "exclude <testname> (can be used multiple times)");
        opt_register_arg("-t|--timeout <milleseconds>", opt_set_uintval,
@@ -671,6 +672,9 @@ int main(int argc, char *argv[])
                           " of CCAN modules.",
                           "This usage message");
 
+       /* Do verbose before anything else... */
+       opt_early_parse(argc, argv, opt_log_stderr_exit);
+
        /* We move into temporary directory, so gcov dumps its files there. */
        if (chdir(temp_dir(talloc_autofree_context())) != 0)
                err(1, "Error changing to %s temporary dir", temp_dir(NULL));
@@ -695,7 +699,6 @@ int main(int argc, char *argv[])
 
        for (i = 1; i < argc; i++) {
                unsigned int score, total_score;
-               bool added_info_options = false;
 
                dir = argv[i];
 
@@ -745,12 +748,6 @@ int main(int argc, char *argv[])
                                        goto next;
                                }
                        }
-
-                       /* --target overrides known FAIL from _info */
-                       if (!added_info_options && m->info_file) {
-                               add_info_options(m->info_file, !target);
-                               added_info_options = true;
-                       }
                }
 
                printf("%sTotal score: %u/%u\n", prefix, score, total_score);