From 2c06b8d75023df1b3a5b92030a2a482fe3b2ce72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Svensson?= Date: Fri, 22 Sep 2023 14:42:56 +0200 Subject: [PATCH 1/2] Fix Clang compiler warnings When building using a newer Clang with additional diagnostics the following warnings are given: -Wunused-but-set-variable -Wstrict-prototypes These issues are corrected in this commit. Reproducable using: CC="clang-13" CFLAGS="-Wall -pedantic" cmake .. --- src/slug.c | 2 -- tests/bench.c | 6 +++--- tests/bench.h | 4 ++-- tests/check_tree.c | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/slug.c b/src/slug.c index 5f89207d..6974f536 100644 --- a/src/slug.c +++ b/src/slug.c @@ -90,7 +90,6 @@ int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char * return 0; } - int cnt = 0; int state = 0; const char * p = offset; @@ -122,7 +121,6 @@ int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char * if (s->pattern) { s->pattern_len = p - s->pattern; } - cnt++; state--; p++; break; diff --git a/tests/bench.c b/tests/bench.c index 9f961e0e..dd8ecc3f 100644 --- a/tests/bench.c +++ b/tests/bench.c @@ -17,7 +17,7 @@ -unsigned long unixtime() { +unsigned long unixtime(void) { struct timeval tp; if (gettimeofday((struct timeval *) &tp, (NULL)) == 0) { return tp.tv_sec; @@ -25,7 +25,7 @@ unsigned long unixtime() { return 0; } -double microtime() { +double microtime(void) { struct timeval tp; long sec = 0L; double msec = 0.0; @@ -93,7 +93,7 @@ void bench_append_csv(char *filename, int countOfB, ...) { -int main() +int main(void) { R3Node * n = r3_tree_create(1); diff --git a/tests/bench.h b/tests/bench.h index 6bbad502..08680d65 100644 --- a/tests/bench.h +++ b/tests/bench.h @@ -22,9 +22,9 @@ typedef struct { double end; } bench; -unsigned long unixtime(); +unsigned long unixtime(void); -double microtime(); +double microtime(void); void bench_start(bench *b); diff --git a/tests/check_tree.c b/tests/check_tree.c index b2ddf8c2..19b6c147 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -304,7 +304,7 @@ START_TEST (test_node_construct_and_free) } END_TEST -static R3Node * create_simple_str_tree() { +static R3Node * create_simple_str_tree(void) { R3Node * n; n = r3_tree_create(10); r3_tree_insert_path(n, "/zoo", NULL); From 7c625f8f4c006ec5bb8059d6b154f84ea4279662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Svensson?= Date: Fri, 22 Sep 2023 15:25:01 +0200 Subject: [PATCH 2/2] Replace use of deprecated libcheck API fail_if() Fixes [-Wformat-extra-args] warnings when built using GCC, See details in: https://github.com/libcheck/check/pull/298 --- tests/check_tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/check_tree.c b/tests/check_tree.c index 19b6c147..5f0f4a58 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -714,19 +714,19 @@ START_TEST(test_route_cmp) R3Route *r1 = r3_node_append_route(n,test_str, strlen(test_str),0,0); match_entry * m = match_entry_create("/blog/post"); - fail_if( r3_route_cmp(r1, m) == -1, "should match"); + ck_assert_msg(r3_route_cmp(r1, m) == 0, "should match"); r1->request_method = METHOD_GET; m->request_method = METHOD_GET; - fail_if( r3_route_cmp(r1, m) == -1, "should match"); + ck_assert_msg(r3_route_cmp(r1, m) == 0, "should match"); r1->request_method = METHOD_GET; m->request_method = METHOD_POST; - fail_if( r3_route_cmp(r1, m) == 0, "should be different"); + ck_assert_msg(r3_route_cmp(r1, m) == -1, "should be different"); r1->request_method = METHOD_GET; m->request_method = METHOD_POST | METHOD_GET; - fail_if( r3_route_cmp(r1, m) == -1, "should match"); + ck_assert_msg(r3_route_cmp(r1, m) == 0, "should match"); match_entry_free(m); r3_tree_free(n);