]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Test: Fixed annoying warnings (and possible obscure bugs).
authorMaria Matejka <mq@ucw.cz>
Fri, 8 Feb 2019 10:19:04 +0000 (11:19 +0100)
committerMaria Matejka <mq@ucw.cz>
Tue, 9 Jul 2019 12:37:14 +0000 (14:37 +0200)
filter/filter_test.c
test/birdtest.c
test/birdtest.h

index be7fd5211cc536735e3d6b854443094536d19c20..916290ed0ac94f13f56659095bd9dfd5f2e43317 100644 (file)
@@ -29,7 +29,7 @@ parse_config_file(const void *filename_void)
 
   size_t fn_size = strlen((const char *) filename_void) + 1;
   char *filename = alloca(fn_size);
-  strncpy(filename, filename_void, fn_size);
+  memcpy(filename, filename_void, fn_size);
 
   struct config *c = bt_config_file_parse(filename);
   bt_bird_cleanup();
index d503890a135eefda19c4a60a009f340221e6580e..7b6fb0b57f153e3be1eb3eabea7d67f909c4272c 100644 (file)
@@ -149,10 +149,7 @@ int bt_run_test_fn(int (*fn)(const void *), const void *fn_arg, int timeout)
   int result;
   alarm(timeout);
 
-  if (fn_arg)
-    result = fn(fn_arg);
-  else
-    result = ((int (*)(void))fn)();
+  result = fn(fn_arg);
 
   if (!bt_suite_result)
     result = 0;
index b2d572d0d8bcfbcaa2e79622af22b8744fc68860..dacfb0952508b7037ba14f87347ca477b1de1de9 100644 (file)
@@ -55,11 +55,13 @@ void bt_log_suite_case_result(int result, const char *fmt, ...);
 #define BT_PROMPT_FAIL_NO_COLOR                " ["                 "FAIL"                  "] "
 #define BT_PROMPT_OK_FAIL_STRLEN       8       /* strlen ' [FAIL] ' */
 
+static inline int bt_test_fn_noarg(const void *cp) { return ((int (*)(void)) cp)(); }
+
 #define bt_test_suite(fn, dsc, ...) \
   bt_test_suite_extra(fn, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__)
 
 #define bt_test_suite_extra(fn, f, t, dsc, ...) \
-  bt_test_suite_base((int (*)(const void *))fn, #fn, NULL, f, t, dsc, ##__VA_ARGS__)
+  bt_test_suite_base(bt_test_fn_noarg, #fn, fn, f, t, dsc, ##__VA_ARGS__)
 
 #define bt_test_suite_arg(fn, arg, dsc, ...) \
   bt_test_suite_arg_extra(fn, arg, BT_FORKING, BT_TIMEOUT, dsc, ##__VA_ARGS__)