]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/compulsory_tests/has_main_header.c
ccanlint: rename test keys
[ccan] / tools / ccanlint / compulsory_tests / has_main_header.c
index c2c823821b3a1e8c6ed65aa41a3c473b23ba3957..338f7af789fece9a2b99f222002d0d777908288e 100644 (file)
 #include <ccan/talloc/talloc.h>
 #include <ccan/noerr/noerr.h>
 
-static void *check_has_main_header(struct manifest *m)
+static void check_has_main_header(struct manifest *m,
+                                 bool keep,
+                                 unsigned int *timeleft, struct score *score)
 {
        struct ccan_file *f;
 
        list_for_each(&m->h_files, f, list) {
                if (strstarts(f->name, m->basename)
-                   && strlen(f->name) == strlen(m->basename) + 2)
-                       return NULL;
+                   && strlen(f->name) == strlen(m->basename) + 2) {
+                       score->pass = true;
+                       score->score = score->total;
+                       return;
+               } 
        }
-       return m;
-}
-
-static const char *describe_has_main_header(struct manifest *m,
-                                           void *check_result)
-{
-       return talloc_asprintf(m,
+       score->error = talloc_asprintf(score,
        "You have no %s/%s.h header file.\n\n"
        "CCAN modules have a name, the same as the directory name.  They're\n"
        "expected to have an interface in the header of the same name.\n",
-                              m->basename, m->basename);
+                                      m->basename, m->basename);
 }
 
 struct ccanlint has_main_header = {
-       .key = "has-main-header",
+       .key = "main_header_exists",
        .name = "Module has main header file",
        .check = check_has_main_header,
-       .describe = describe_has_main_header,
 };
 
 REGISTER_TEST(has_main_header, NULL);