X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fbuild_objs.c;h=2f189e859f25a8b523505609cafd31c429e3a443;hp=e0ea222350bc981ed3075270a0db3ee7459cf1f1;hb=687cde2a8c561b68f17609b615eb930ea02f5aac;hpb=5b7e9d904afa72961340c225de39daab29ff7d0e diff --git a/tools/ccanlint/tests/build_objs.c b/tools/ccanlint/tests/build_objs.c index e0ea2223..2f189e85 100644 --- a/tools/ccanlint/tests/build_objs.c +++ b/tools/ccanlint/tests/build_objs.c @@ -21,50 +21,31 @@ static const char *can_build(struct manifest *m) return NULL; } -static bool compile_obj(struct ccan_file *c_file, char *objfile, char **report) -{ - char *err; - - err = compile_object(objfile, objfile, c_file->name); - if (err) { - if (*report) - *report = talloc_append_string(*report, err); - else - *report = err; - return false; - } - return true; -} - -static int cleanup_obj(char *objfile) -{ - unlink(objfile); - return 0; -} - static void *check_objs_build(struct manifest *m) { char *report = NULL; struct ccan_file *i; - /* One point for each obj file. */ - list_for_each(&m->c_files, i, list) - build_objs.total_score++; - list_for_each(&m->c_files, i, list) { - char *objfile = talloc_strdup(m, i->name); - objfile[strlen(objfile)-1] = 'o'; + char *err; + + /* One point for each obj file. */ + build_objs.total_score++; - if (compile_obj(i, objfile, &report)) - talloc_set_destructor(objfile, cleanup_obj); + i->compiled = compile_object(m, i->name, &err); + if (!i->compiled) { + if (report) + report = talloc_append_string(report, err); + else + report = err; + } } return report; } static const char *describe_objs_build(struct manifest *m, void *check_result) { - return talloc_asprintf(check_result, - "%s", (char *)check_result); + return check_result; } struct ccanlint build_objs = {