X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fno_trailing_whitespace.c;h=bba51d8c5a3acd9e65c76044ee09194046ae7193;hp=5c5cf35bb68769ea1276756ac7a34c99147f5b1d;hb=dc8042b42500f79f613b1197df6cdf739615a89f;hpb=af5b1a18948345c5f9f9abf4eda3ab9fe0aa9a9f diff --git a/tools/ccanlint/tests/no_trailing_whitespace.c b/tools/ccanlint/tests/no_trailing_whitespace.c index 5c5cf35b..bba51d8c 100644 --- a/tools/ccanlint/tests/no_trailing_whitespace.c +++ b/tools/ccanlint/tests/no_trailing_whitespace.c @@ -1,11 +1,11 @@ /* Trailing whitespace test. Almost embarrassing, but trivial. */ #include -#include #include #include +#include /* FIXME: only print full analysis if verbose >= 2. */ -static char *get_trailing_whitespace(const char *line) +static char *get_trailing_whitespace(const tal_t *ctx, const char *line) { const char *e = strchr(line, 0); while (e>line && (e[-1]==' ' || e[-1]=='\t')) @@ -16,9 +16,8 @@ static char *get_trailing_whitespace(const char *line) return NULL; //the line only consists of spaces if (strlen(line) > 20) - return talloc_asprintf(line, "...'%s'", - line + strlen(line) - 20); - return talloc_asprintf(line, "'%s'", line); + return tal_fmt(ctx, "...'%s'", line + strlen(line) - 20); + return tal_fmt(ctx, "'%s'", line); } static void check_trailing_whitespace(struct manifest *m, @@ -36,7 +35,8 @@ static void check_trailing_whitespace(struct manifest *m, list_for_each(list, f, list) { char **lines = get_ccan_file_lines(f); for (i = 0; i < f->num_lines; i++) { - char *err = get_trailing_whitespace(lines[i]); + char *err = get_trailing_whitespace(score, + lines[i]); if (err) score_file_error(score, f, i+1, "%s", err);