X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ffile_analysis.c;h=f2ee5d74c005467934c3e738a8f453963e3edb64;hb=32a31d9e4fb1f312a47ae8c237ac30d6c1567ccd;hp=44ea5c2dab9fd8a2760bc96a25f50a033cae22d9;hpb=61088f5c752c555172e2ab6cf93a7967f79f3f2c;p=ccan diff --git a/tools/ccanlint/file_analysis.c b/tools/ccanlint/file_analysis.c index 44ea5c2d..f2ee5d74 100644 --- a/tools/ccanlint/file_analysis.c +++ b/tools/ccanlint/file_analysis.c @@ -40,6 +40,7 @@ struct ccan_file *new_ccan_file(const void *ctx, char *name) f->lines = NULL; f->line_info = NULL; f->doc_sections = NULL; + f->compiled = NULL; f->name = talloc_steal(f, name); return f; } @@ -115,7 +116,7 @@ static void add_files(struct manifest *m, const char *dir) else if (strstarts(f->name, "test/compile_fail")) dest = &m->compile_fail_tests; else - dest = &m->other_test_files; + dest = &m->other_test_c_files; } else dest = &m->other_test_files; } else @@ -150,9 +151,10 @@ char *report_on_lines(struct list_head *files, return sofar; } -struct manifest *get_manifest(const void *ctx) +struct manifest *get_manifest(const void *ctx, const char *dir) { struct manifest *m = talloc(ctx, struct manifest); + char *olddir; unsigned int len; m->info_file = NULL; @@ -162,11 +164,19 @@ struct manifest *get_manifest(const void *ctx) list_head_init(&m->run_tests); list_head_init(&m->compile_ok_tests); list_head_init(&m->compile_fail_tests); + list_head_init(&m->other_test_c_files); 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) + err(1, "Getting current directory"); + + if (chdir(dir) != 0) + err(1, "Failed to chdir to %s", dir); + m->basename = talloc_getcwd(m); if (!m->basename) err(1, "Getting current directory"); @@ -180,6 +190,11 @@ struct manifest *get_manifest(const void *ctx) m->basename++; add_files(m, ""); + + if (chdir(olddir) != 0) + err(1, "Returning to original directory '%s'", olddir); + talloc_free(olddir); + return m; }