]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/file_analysis.c
ccanlint: use traversal to trim tests we want to skip.
[ccan] / tools / ccanlint / file_analysis.c
index d55e2b8c12bebd7b4d4062ed93b1d7350ae8216e..63d22b8f129513420101f618f459ed4878a34c54 100644 (file)
@@ -10,6 +10,7 @@
 #include <ccan/noerr/noerr.h>
 #include <ccan/foreach/foreach.h>
 #include <ccan/asort/asort.h>
+#include <ccan/array_size/array_size.h>
 #include "../tools.h"
 #include <unistd.h>
 #include <sys/types.h>
@@ -39,7 +40,8 @@ static bool dir_cmp(const struct manifest *m, const char *dir)
        return strcmp(m->dir, dir) == 0;
 }
 
-HTABLE_DEFINE_TYPE(struct manifest, manifest_name, dir_hash, dir_cmp, manifest);
+HTABLE_DEFINE_TYPE(struct manifest, manifest_name, dir_hash, dir_cmp,
+                  htable_manifest);
 static struct htable_manifest *manifests;
 
 const char *get_ccan_file_contents(struct ccan_file *f)
@@ -74,6 +76,7 @@ struct list_head *get_ccan_file_docs(struct ccan_file *f)
 struct ccan_file *new_ccan_file(const void *ctx, const char *dir, char *name)
 {
        struct ccan_file *f;
+       unsigned int i;
 
        assert(dir[0] == '/');
 
@@ -81,11 +84,11 @@ struct ccan_file *new_ccan_file(const void *ctx, const char *dir, char *name)
        f->lines = NULL;
        f->line_info = NULL;
        f->doc_sections = NULL;
-       f->compiled = NULL;
+       for (i = 0; i < ARRAY_SIZE(f->compiled); i++)
+               f->compiled[i] = NULL;
        f->name = talloc_steal(f, name);
        f->fullname = talloc_asprintf(f, "%s/%s", dir, f->name);
        f->contents = NULL;
-       f->cov_compiled = NULL;
        f->simplified = NULL;
        return f;
 }
@@ -209,8 +212,10 @@ struct manifest *get_manifest(const void *ctx, const char *dir)
        unsigned int len;
        struct list_head *list;
 
-       if (!manifests)
-               manifests = htable_manifest_new();
+       if (!manifests) {
+               manifests = talloc(NULL, struct htable_manifest);
+               htable_manifest_init(manifests);
+       }
 
        olddir = talloc_getcwd(NULL);
        if (!olddir)
@@ -229,7 +234,7 @@ struct manifest *get_manifest(const void *ctx, const char *dir)
 
        m = talloc_linked(ctx, talloc(NULL, struct manifest));
        m->info_file = NULL;
-       m->compiled = NULL;
+       m->compiled[COMPILE_NORMAL] = m->compiled[COMPILE_NOFEAT] = NULL;
        m->dir = talloc_steal(m, canon_dir);
        list_head_init(&m->c_files);
        list_head_init(&m->h_files);