X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Fcompulsory_tests%2Fhas_main_header.c;h=68ea1359581d59dc0fd11e8db3202dc9dfe0d652;hb=2926cafb52b9d95646d9dafa877d53f2368d8b2c;hp=dafb41a6e8d71bcf1f6bb5a02a209f6b09b8ce9b;hpb=304652023042670b3173de0ad5dc0eb7c836618c;p=ccan-lca-2011.git diff --git a/tools/ccanlint/compulsory_tests/has_main_header.c b/tools/ccanlint/compulsory_tests/has_main_header.c index dafb41a..68ea135 100644 --- a/tools/ccanlint/compulsory_tests/has_main_header.c +++ b/tools/ccanlint/compulsory_tests/has_main_header.c @@ -12,33 +12,32 @@ #include #include -static void *check_has_main_header(struct manifest *m, unsigned int *timeleft) +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", +struct ccanlint main_header_exists = { + .key = "main_header_exists", .name = "Module has main header file", .check = check_has_main_header, - .describe = describe_has_main_header, + .needs = "" }; -REGISTER_TEST(has_main_header, NULL); +REGISTER_TEST(main_header_exists);