X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ffile_analysis.c;h=25e36743c51906206f1d99179b083f26a7084adf;hp=8fbb7186c91213127837108228581c92dcac534f;hb=979071e8587d4819a7f78613b68d29e222e5db63;hpb=5f551788224a3cf0988ae490a807b20292822f20 diff --git a/tools/ccanlint/file_analysis.c b/tools/ccanlint/file_analysis.c index 8fbb7186..25e36743 100644 --- a/tools/ccanlint/file_analysis.c +++ b/tools/ccanlint/file_analysis.c @@ -357,18 +357,13 @@ enum line_compiled get_ccan_line_pp(struct pp_conditions *cond, } ret = get_pp(cond, head); tal_free(head); + va_end(ap); return ret; } -void score_file_error(struct score *score, struct ccan_file *f, unsigned line, - const char *errorfmt, ...) +static void score_error_vfmt(struct score *score, const char *source, + const char *errorfmt, va_list ap) { - va_list ap; - - struct file_error *fe = tal(score, struct file_error); - fe->file = f; - fe->line = line; - list_add_tail(&score->per_file_errors, &fe->list); if (!score->error) score->error = tal_strdup(score, ""); @@ -384,18 +379,46 @@ void score_file_error(struct score *score, struct ccan_file *f, unsigned line, return; } + tal_append_fmt(&score->error, "%s:", source); + tal_append_vfmt(&score->error, errorfmt, ap); + score->error = tal_strcat(score, take(score->error), "\n"); +} + + + +void score_error(struct score *score, const char *source, + const char *errorfmt, ...) +{ + va_list ap; + + va_start(ap, errorfmt); + score_error_vfmt(score, source, errorfmt, ap); + va_end(ap); +} + +void score_file_error(struct score *score, struct ccan_file *f, unsigned line, + const char *errorfmt, ...) +{ + va_list ap; + char *source; + + struct file_error *fe = tal(score, struct file_error); + fe->file = f; + fe->line = line; + list_add_tail(&score->per_file_errors, &fe->list); + if (line) - tal_append_fmt(&score->error, "%s:%u:", f->fullname, line); + source = tal_fmt(score, "%s:%u", f->fullname, line); else - tal_append_fmt(&score->error, "%s:", f->fullname); + source = tal_fmt(score, "%s", f->fullname); va_start(ap, errorfmt); - tal_append_vfmt(&score->error, errorfmt, ap); + score_error_vfmt(score, source, errorfmt, ap); va_end(ap); - score->error = tal_strcat(score, take(score->error),"\n"); } -char *get_or_compile_info(const void *ctx, const char *dir) + +char *get_or_compile_info(const void *ctx UNNEEDED, const char *dir) { struct manifest *m = get_manifest(NULL, dir);