From 1d893107b3481639bf1fc6f96972457ac6e828f7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 7 Jun 2010 16:34:15 +0930 Subject: [PATCH] ccanlint: make sure fullname is always full path name. --- tools/ccanlint/ccanlint.h | 2 -- tools/ccanlint/compulsory_tests/check_build.c | 7 ++++--- .../compulsory_tests/check_depends_built.c | 15 +++++---------- .../compulsory_tests/check_depends_exist.c | 8 +++----- tools/ccanlint/compulsory_tests/compile_tests.c | 6 ++++-- tools/ccanlint/file_analysis.c | 4 +++- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/tools/ccanlint/ccanlint.h b/tools/ccanlint/ccanlint.h index 2ddbf37a..6680f4f0 100644 --- a/tools/ccanlint/ccanlint.h +++ b/tools/ccanlint/ccanlint.h @@ -31,8 +31,6 @@ struct manifest { /* From tests/check_depends_exist.c */ struct list_head dep_dirs; - /* From tests/check_depends_built.c */ - struct list_head dep_objs; }; struct manifest *get_manifest(const void *ctx, const char *dir); diff --git a/tools/ccanlint/compulsory_tests/check_build.c b/tools/ccanlint/compulsory_tests/check_build.c index 2098f0d2..5031cf84 100644 --- a/tools/ccanlint/compulsory_tests/check_build.c +++ b/tools/ccanlint/compulsory_tests/check_build.c @@ -27,9 +27,10 @@ static char *obj_list(const struct manifest *m) struct ccan_file *i; /* Other CCAN deps. */ - list_for_each(&m->dep_objs, i, list) - list = talloc_asprintf_append(list, "%s ", i->name); - + list_for_each(&m->dep_dirs, i, list) { + if (i->compiled) + list = talloc_asprintf_append(list, "%s ", i->compiled); + } return list; } diff --git a/tools/ccanlint/compulsory_tests/check_depends_built.c b/tools/ccanlint/compulsory_tests/check_depends_built.c index c261315d..497a22c1 100644 --- a/tools/ccanlint/compulsory_tests/check_depends_built.c +++ b/tools/ccanlint/compulsory_tests/check_depends_built.c @@ -42,21 +42,16 @@ static void *check_depends_built(struct manifest *m, unsigned int *timeleft) char *report = NULL; list_for_each(&m->dep_dirs, i, list) { - char *objfile; - if (!expect_obj_file(i->fullname)) continue; - objfile = talloc_asprintf(m, "%s.o", i->fullname); - if (stat(objfile, &st) != 0) { + i->compiled = talloc_asprintf(i, "%s.o", i->fullname); + if (stat(i->compiled, &st) != 0) { report = talloc_asprintf_append(report, "object file %s\n", - objfile); - } else { - struct ccan_file *f = new_ccan_file(m, "", objfile); - list_add_tail(&m->dep_objs, &f->list); - } - + i->compiled); + i->compiled = NULL; + } } /* We may need libtap for testing, unless we're "tap" */ diff --git a/tools/ccanlint/compulsory_tests/check_depends_exist.c b/tools/ccanlint/compulsory_tests/check_depends_exist.c index bb6067ed..4a77d7e0 100644 --- a/tools/ccanlint/compulsory_tests/check_depends_exist.c +++ b/tools/ccanlint/compulsory_tests/check_depends_exist.c @@ -16,19 +16,17 @@ static char *add_dep(char *sofar, struct manifest *m, const char *dep) { - char *dir; struct stat st; struct ccan_file *f; - dir = talloc_asprintf(m, "%s/%s", ccan_dir, dep); - if (stat(dir, &st) != 0) { + f = new_ccan_file(m, ccan_dir, talloc_strdup(m, dep)); + if (stat(f->fullname, &st) != 0) { return talloc_asprintf_append(sofar, "ccan/%s: expected it in" " directory %s\n", - dep, dir); + dep, f->fullname); } - f = new_ccan_file(m, "", dir); list_add_tail(&m->dep_dirs, &f->list); return sofar; } diff --git a/tools/ccanlint/compulsory_tests/compile_tests.c b/tools/ccanlint/compulsory_tests/compile_tests.c index 1e184f2d..c6527ed5 100644 --- a/tools/ccanlint/compulsory_tests/compile_tests.c +++ b/tools/ccanlint/compulsory_tests/compile_tests.c @@ -40,8 +40,10 @@ static char *obj_list(const struct manifest *m, bool link_with_module) list = talloc_asprintf_append(list, " %s.o", m->dir); /* Other ccan modules. */ - list_for_each(&m->dep_objs, i, list) - list = talloc_asprintf_append(list, " %s", i->name); + list_for_each(&m->dep_dirs, i, list) { + if (i->compiled) + list = talloc_asprintf_append(list, " %s", i->compiled); + } return list; } diff --git a/tools/ccanlint/file_analysis.c b/tools/ccanlint/file_analysis.c index c03931d8..93baf8eb 100644 --- a/tools/ccanlint/file_analysis.c +++ b/tools/ccanlint/file_analysis.c @@ -14,6 +14,7 @@ #include #include #include +#include const char *ccan_dir; @@ -38,6 +39,8 @@ struct ccan_file *new_ccan_file(const void *ctx, const char *dir, char *name) { struct ccan_file *f; + assert(dir[0] == '/'); + f = talloc(ctx, struct ccan_file); f->lines = NULL; f->line_info = NULL; @@ -172,7 +175,6 @@ struct manifest *get_manifest(const void *ctx, const char *dir) list_head_init(&m->other_test_files); list_head_init(&m->other_files); list_head_init(&m->dep_dirs); - list_head_init(&m->dep_objs); olddir = talloc_getcwd(NULL); if (!olddir) -- 2.39.2