Browse Source

tests: fix warnings

While I don't see -Werror being used on tests anytime soon, there's no
reason to keep the warnings in tests unfixed.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter 3 years ago
parent
commit
c313895dec

+ 2 - 2
tests/Makefile.am

@@ -36,14 +36,14 @@ check_PROGRAMS = testsig testsegv testbuffer testmemory heavy heavywq heavythrea
 
 test-commands-defun.c: ../vtysh/vtysh_cmd.c
 	sed \
-		-e '/"vtysh.h"/d' \
+		-e 's/"vtysh\.h"/"tests.h"/' \
 		-e 's/vtysh_init_cmd/test_init_cmd/' \
 		-e 's/VTYSH_[A-Z][A-Z_0-9]*/0/g' \
 		< ../vtysh/vtysh_cmd.c \
 		> test-commands-defun.c
 
 BUILT_SOURCES = test-commands-defun.c
-noinst_HEADERS = prng.h
+noinst_HEADERS = prng.h tests.h
 
 testsig_SOURCES = test-sig.c
 testsegv_SOURCES = test-segv.c

+ 1 - 1
tests/bgp_mp_attr_test.c

@@ -545,7 +545,7 @@ main (void)
     return -1;
   
   peer = peer_create_accept (bgp);
-  peer->host = "foo";
+  peer->host = (char *)"foo";
   
   for (i = AFI_IP; i < AFI_MAX; i++)
     for (j = SAFI_UNICAST; j < SAFI_MAX; j++)

+ 1 - 1
tests/bgp_mpath_test.c

@@ -252,7 +252,7 @@ run_bgp_mp_list (testcase_t *t)
   bgp_mp_list_add (&mp_list, &test_mp_list_info[3]);
   bgp_mp_list_add (&mp_list, &test_mp_list_info[0]);
 
-  for (i = 0, mp_node = listhead(&mp_list); i < test_mp_list_info_count;
+  for (i = 0, mp_node = mp_list.head; i < test_mp_list_info_count;
        i++, mp_node = listnextnode(mp_node))
     {
       info = listgetdata(mp_node);

+ 1 - 1
tests/ecommunity_test.c

@@ -132,7 +132,7 @@ parse_test (struct test_segment *t)
   
   printf ("%s: %s\n", t->name, t->desc);
 
-  ecom = ecommunity_parse (t->data, t->len);
+  ecom = ecommunity_parse ((u_int8_t *)t->data, t->len);
 
   printf ("ecom: %s\nvalidating...:\n", ecommunity_str (ecom));
 

+ 2 - 0
tests/heavy-thread.c

@@ -37,6 +37,8 @@
 #include "memory.h"
 #include "log.h"
 
+#include "tests.h"
+
 extern struct thread_master *master;
 
 enum

+ 2 - 0
tests/heavy-wq.c

@@ -36,6 +36,8 @@
 #include "workqueue.h"
 #include <math.h>
 
+#include "tests.h"
+
 extern struct thread_master *master;
 static struct work_queue *heavy_wq;
 

+ 2 - 0
tests/heavy.c

@@ -36,6 +36,8 @@
 #include "memory.h"
 #include <math.h>
 
+#include "tests.h"
+
 enum
 {
   ITERS_FIRST = 0,

+ 1 - 1
tests/main.c

@@ -52,7 +52,7 @@ DEFUN (daemon_exit,
 }
 
 static int timer_count;
-int
+static int
 test_timer (struct thread *thread)
 {
   int *count = THREAD_ARG(thread);

+ 0 - 35
tests/test-checksum.c

@@ -46,41 +46,6 @@ typedef uint16_t testoff_t;
 /* Fletcher Checksum -- Refer to RFC1008. */
 #define MODX                 4102
 
-/* Accumulator phase of checksum */
-static 
-struct acc_vals
-accumulate (u_char *buffer, testsz_t len, testoff_t off)
-{
-  u_int8_t *p;
-  u_int16_t *csum;
-  int i, partial_len;
-  struct acc_vals ret;
-  
-  csum = (u_int16_t *) (buffer + off);
-  *(csum) = 0;
-  
-  p = buffer;
-  ret.c0 = 0;
-  ret.c1 = 0;
-  
-  while (len != 0)
-    {
-      partial_len = MIN(len, MODX);
-
-      for (i = 0; i < partial_len; i++)
-	{
-	  ret.c0 = ret.c0 + *(p++);
-	  ret.c1 += ret.c0;
-	}
-
-      ret.c0 = ret.c0 % 255;
-      ret.c1 = ret.c1 % 255;
-
-      len -= partial_len;
-    }
-  return ret;
-}
-
 /* The final reduction phase.
  * This one should be the original ospfd version 
  */

+ 1 - 1
tests/test-segv.c

@@ -35,7 +35,7 @@ struct quagga_signal_t sigs[] =
 
 struct thread_master *master;
 
-int
+static int
 threadfunc (struct thread *thread)
 {
   int *null = NULL;

+ 3 - 3
tests/test-sig.c

@@ -22,19 +22,19 @@
 #include "lib/log.h"
 #include "lib/memory.h"
 
-void
+static void
 sighup (void)
 {
   printf ("processed hup\n");
 }
 
-void
+static void
 sigusr1 (void)
 {
   printf ("processed usr1\n");
 }
 
-void
+static void
 sigusr2 (void)
 {
   printf ("processed usr2\n");

+ 6 - 3
tests/test-timer-correctness.c

@@ -140,8 +140,9 @@ int main(int argc, char **argv)
       interval_msec = prng_rand(prng) % 5000;
       arg = XMALLOC(MTYPE_TMP, TIMESTR_LEN + 1);
       timers[i] = thread_add_timer_msec(master, timer_func, arg, interval_msec);
-      ret = snprintf(arg, TIMESTR_LEN + 1, "%ld.%06ld",
-                     timers[i]->u.sands.tv_sec, timers[i]->u.sands.tv_usec);
+      ret = snprintf(arg, TIMESTR_LEN + 1, "%lld.%06lld",
+                     (long long)timers[i]->u.sands.tv_sec,
+                     (long long)timers[i]->u.sands.tv_usec);
       assert(ret > 0);
       assert((size_t)ret < TIMESTR_LEN + 1);
       timers_pending++;
@@ -180,7 +181,9 @@ int main(int argc, char **argv)
 
       ret = snprintf(expected_buf + expected_buf_pos,
                      expected_buf_len - expected_buf_pos,
-                     "%ld.%06ld\n", alarms[i]->tv_sec, alarms[i]->tv_usec);
+                     "%lld.%06lld\n",
+                     (long long)alarms[i]->tv_sec,
+                     (long long)alarms[i]->tv_usec);
       assert(ret > 0);
       expected_buf_pos += ret;
       assert(expected_buf_pos < expected_buf_len);

+ 31 - 0
tests/tests.h

@@ -0,0 +1,31 @@
+/*
+ * Test wrappers common header file
+ *
+ * Copyright (C) 2015 by David Lamparter,
+ *                    for Open Source Routing./ NetDEF, Inc.
+ *
+ * This file is part of Quagga
+ *
+ * Quagga is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * Quagga is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Quagga; see the file COPYING.  If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_TESTS_H
+#define _QUAGGA_TESTS_H
+
+extern void test_init (void);
+extern void test_init_cmd (void);
+
+#endif /* _QUAGGA_TESTS_H */