From 9961094e2422cf0c2d9cb21387da7c65ddddafe2 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 5 Nov 2016 07:23:47 +1030 Subject: [PATCH 1/1] tools/ccanlint: compile cleanly with -Wextra. Signed-off-by: Rusty Russell --- tools/ccanlint/async.c | 2 +- tools/ccanlint/ccanlint.c | 34 ++++++++++++++----------- tools/ccanlint/file_analysis.c | 2 +- tools/ccanlint/tests/examples_compile.c | 4 +-- tools/manifest.c | 2 +- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/tools/ccanlint/async.c b/tools/ccanlint/async.c index d867079d..e5b9078d 100644 --- a/tools/ccanlint/async.c +++ b/tools/ccanlint/async.c @@ -34,7 +34,7 @@ struct command { const void *ctx; }; -static void killme(int sig) +static void killme(int sig UNNEEDED) { kill(-getpid(), SIGKILL); } diff --git a/tools/ccanlint/ccanlint.c b/tools/ccanlint/ccanlint.c index e2a687e0..629ffd51 100644 --- a/tools/ccanlint/ccanlint.c +++ b/tools/ccanlint/ccanlint.c @@ -84,12 +84,12 @@ static bool skip_test(struct dgraph_node *node, const char *why) return true; } -static const char *dep_failed(struct manifest *m) +static const char *dep_failed(struct manifest *m UNNEEDED) { return "dependency couldn't run"; } -static bool cannot_run(struct dgraph_node *node, void *all) +static bool cannot_run(struct dgraph_node *node, void *all UNNEEDED) { struct ccanlint *c = container_of(node, struct ccanlint, node); c->can_run = dep_failed; @@ -215,7 +215,7 @@ static void register_test(struct ccanlint *test) dgraph_init_node(&test->node); } -static bool get_test(const char *member, struct ccanlint *i, +static bool get_test(const char *member UNNEEDED, struct ccanlint *i, struct ccanlint **ret) { if (tlist_empty(&i->node.edge[DGRAPH_TO])) { @@ -252,7 +252,8 @@ bool is_excluded(const char *name) return find_test(name)->skip != NULL; } -static bool init_deps(const char *member, struct ccanlint *c, void *unused) +static bool init_deps(const char *member UNNEEDED, + struct ccanlint *c, void *unused UNNEEDED) { char **deps = tal_strsplit(NULL, c->needs, " ", STR_EMPTY_OK); unsigned int i; @@ -270,7 +271,7 @@ static bool init_deps(const char *member, struct ccanlint *c, void *unused) return true; } -static bool check_names(const char *member, struct ccanlint *c, +static bool check_names(const char *member UNNEEDED, struct ccanlint *c, ccanlint_map_t *names) { if (!strmap_add(names, c->name, c)) @@ -299,7 +300,7 @@ static void init_tests(void) strmap_clear(&names); } -static bool reset_test(struct dgraph_node *node, void *unused) +static bool reset_test(struct dgraph_node *node, void *unused UNNEEDED) { struct ccanlint *c = container_of(node, struct ccanlint, node); c->skip = NULL; @@ -312,7 +313,8 @@ static void reset_tests(struct dgraph_node *all) dgraph_traverse_to(all, reset_test, NULL); } -static bool print_deps(const char *member, struct ccanlint *c, void *unused) +static bool print_deps(const char *member UNNEEDED, + struct ccanlint *c, void *unused UNNEEDED) { if (!tlist_empty(&c->node.edge[DGRAPH_FROM])) { struct dgraph_edge *e; @@ -341,7 +343,7 @@ static void show_tmpdir(const char *dir) printf("You can find ccanlint working files in '%s'\n", dir); } -static char *keep_tests(void *unused) +static char *keep_tests(void *unused UNNEEDED) { keep_results = true; @@ -359,7 +361,7 @@ static bool remove_test(struct dgraph_node *node, const char *why) return true; } -static char *exclude_test(const char *testname, void *unused) +static char *exclude_test(const char *testname, void *unused UNNEEDED) { struct ccanlint *i = find_test(testname); if (!i) @@ -378,7 +380,7 @@ static void skip_test_and_deps(struct ccanlint *c, const char *why) skip_test(&c->node, why); } -static char *list_tests(void *arg) +static char *list_tests(void *arg UNNEEDED) { struct ccanlint *i; @@ -392,7 +394,8 @@ static char *list_tests(void *arg) exit(0); } -static bool draw_test(const char *member, struct ccanlint *c, const char *style) +static bool draw_test(const char *member UNNEEDED, + struct ccanlint *c, const char *style) { /* * todo: escape labels in case ccanlint test keys have @@ -407,7 +410,8 @@ static void test_dgraph_vertices(const char *style) strmap_iterate(&tests, draw_test, style); } -static bool draw_edges(const char *member, struct ccanlint *c, void *unused) +static bool draw_edges(const char *member UNNEEDED, + struct ccanlint *c, void *unused UNNEEDED) { struct dgraph_edge *e; @@ -425,7 +429,7 @@ static void test_dgraph_edges(void) strmap_iterate(&tests, draw_edges, NULL); } -static char *test_dependency_graph(void *arg) +static char *test_dependency_graph(void *arg UNNEEDED) { puts("digraph G {"); @@ -586,7 +590,7 @@ static bool run_tests(struct dgraph_node *all, return run.pass; } -static bool add_to_all(const char *member, struct ccanlint *c, +static bool add_to_all(const char *member UNNEEDED, struct ccanlint *c, struct dgraph_node *all) { /* If we're excluded on cmdline, don't add. */ @@ -614,7 +618,7 @@ static bool test_module(struct dgraph_node *all, int main(int argc, char *argv[]) { bool summary = false, pass = true, deps_fail_ignore = false; - unsigned int i; + int i; const char *prefix = ""; char *cwd = path_cwd(NULL), *dir; struct ccanlint top; /* cannot_run may try to set ->can_run */ diff --git a/tools/ccanlint/file_analysis.c b/tools/ccanlint/file_analysis.c index abcf0795..d2fe2a4c 100644 --- a/tools/ccanlint/file_analysis.c +++ b/tools/ccanlint/file_analysis.c @@ -417,7 +417,7 @@ void score_file_error(struct score *score, struct ccan_file *f, unsigned line, } -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); diff --git a/tools/ccanlint/tests/examples_compile.c b/tools/ccanlint/tests/examples_compile.c index 74586066..cb71bf83 100644 --- a/tools/ccanlint/tests/examples_compile.c +++ b/tools/ccanlint/tests/examples_compile.c @@ -485,7 +485,7 @@ static struct ccan_file *mangle_example(struct manifest *m, return NULL; contents = mangle(m, lines); - if (write(fd, contents, strlen(contents)) != strlen(contents)) { + if (write(fd, contents, strlen(contents)) != (int)strlen(contents)) { close(fd); return NULL; } @@ -550,7 +550,7 @@ static unsigned int try_compiling(struct manifest *m, } static void build_examples(struct manifest *m, - unsigned int *timeleft, struct score *score) + unsigned int *timeleft UNNEEDED, struct score *score) { struct ccan_file *i; char **prev = NULL; diff --git a/tools/manifest.c b/tools/manifest.c index 3494937a..82668acf 100644 --- a/tools/manifest.c +++ b/tools/manifest.c @@ -183,7 +183,7 @@ static void add_files(struct manifest *m, const char *base, const char *subdir) } static int cmp_names(struct ccan_file *const *a, struct ccan_file *const *b, - void *unused) + void *unused UNNEEDED) { return strcmp((*a)->name, (*b)->name); } -- 2.39.2