/* Similarly for ->doc_sections */
struct list_head *get_ccan_file_docs(struct ccan_file *f);
-
/* Add an error about this file (and line, if non-zero) to the score struct */
void score_file_error(struct score *, struct ccan_file *f, unsigned line,
const char *error);
unsigned int *timeleft,
struct score *score)
{
- struct ccan_file *f;
+ struct ccan_file *f, *mainh = NULL; /* gcc complains uninitialized */
struct doc_section *d;
bool have_info_example = false, have_header_example = false;
|| strlen(f->name) != strlen(m->basename) + 2)
continue;
+ mainh = f;
list_for_each(get_ccan_file_docs(f), d, list) {
if (streq(d->type, "example")) {
score->error = add_example(m, f, keep, d);
}
}
- if (!have_info_example && !have_header_example) {
- score->error = "You don't have any Example: sections";
- score->score = 0;
- } else if (!have_info_example) {
- score->error = "You don't have an Example: section in _info";
- score->score = 1;
- score->pass = true;
- } else if (!have_header_example) {
- score->error = talloc_asprintf(score,
- "You don't have an Example: section in %s.h",
- m->basename);
- score->score = 1;
- score->pass = true;
- } else {
+ if (have_info_example && have_header_example) {
score->score = score->total;
score->pass = true;
+ return;
}
+
+ score->error = "Expect examples in header and _info";
+ if (!have_info_example)
+ score_file_error(score, m->info_file, 0, "No Example: section");
+ if (!have_header_example)
+ score_file_error(score, mainh, 0, "No Example: section");
+
+ score->score = have_info_example + have_header_example;
+ /* We pass if we find any example. */
+ score->pass = score->score != 0;
}
struct ccanlint has_examples = {
/* FIXME: We assume small headers probably uninteresting. */
return true;
- score->error = "Headers are not idempotent";
for (i = 0; i < f->num_lines; i++) {
if (line_info[i].type == DOC_LINE
|| line_info[i].type == COMMENT_LINE)
struct ccan_file *f;
list_for_each(&m->h_files, f, list) {
- if (!check_idem(f, score))
+ if (!check_idem(f, score)) {
+ score->error = "Headers are not idempotent";
return;
+ }
}
score->pass = true;
score->score = score->total;