X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fheaders_idempotent.c;h=79e5c367d3a35d0dc4c433605a83512e17dee9c8;hp=55fa9974b6d37c08edd6fc004e7068fdf25be974;hb=HEAD;hpb=5f551788224a3cf0988ae490a807b20292822f20 diff --git a/tools/ccanlint/tests/headers_idempotent.c b/tools/ccanlint/tests/headers_idempotent.c index 55fa9974..79e5c367 100644 --- a/tools/ccanlint/tests/headers_idempotent.c +++ b/tools/ccanlint/tests/headers_idempotent.c @@ -13,14 +13,6 @@ #include #include -static const char explain[] -= "Headers usually start with the C preprocessor lines to prevent multiple\n" - "inclusions. These look like the following:\n" - "#ifndef CCAN__H\n" - "#define CCAN__H\n" - "...\n" - "#endif /* CCAN__H */\n"; - static void fix_name(char *name) { unsigned int i; @@ -125,9 +117,10 @@ static void check_idem(struct ccan_file *f, struct score *score) if (!f->lines[i]) return; - /* We expect a condition on this line. */ + /* We expect a condition around this line. */ if (!line_info[i].cond) { - score_file_error(score, f, i+1, "Expected #ifndef"); + score_file_error(score, f, first_preproc_line+1, + "Expected #ifndef"); return; } @@ -136,7 +129,8 @@ static void check_idem(struct ccan_file *f, struct score *score) /* We expect the condition to be ! IFDEF . */ if (line_info[i].cond->type != PP_COND_IFDEF || !line_info[i].cond->inverse) { - score_file_error(score, f, i+1, "Expected #ifndef"); + score_file_error(score, f, first_preproc_line+1, + "Expected #ifndef"); return; } @@ -157,6 +151,9 @@ static void check_idem(struct ccan_file *f, struct score *score) return; } + /* Record this for use in depends_accurate */ + f->idempotent_cond = line_info[i].cond; + /* Rest of code should all be covered by that conditional. */ for (i++; f->lines[i]; i++) { unsigned int val = 0; @@ -173,7 +170,8 @@ static void check_idem(struct ccan_file *f, struct score *score) } static void check_idempotent(struct manifest *m, - unsigned int *timeleft, struct score *score) + unsigned int *timeleft UNNEEDED, + struct score *score) { struct ccan_file *f;