]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: fix warnings
authorDavid Lamparter <equinox@opensourcerouting.org>
Tue, 21 Apr 2015 08:02:23 +0000 (10:02 +0200)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Thu, 26 May 2016 15:33:29 +0000 (15:33 +0000)
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>
(cherry picked from commit c313895dec3c176584d99f7b8684ddc3f9141d88)

13 files changed:
tests/Makefile.am
tests/bgp_mp_attr_test.c
tests/bgp_mpath_test.c
tests/ecommunity_test.c
tests/heavy-thread.c
tests/heavy-wq.c
tests/heavy.c
tests/main.c
tests/test-checksum.c
tests/test-segv.c
tests/test-sig.c
tests/test-timer-correctness.c
tests/tests.h [new file with mode: 0644]

index 7e9ebd0608057b4faf3401354294cc223ace093e..bf1a912f2ee0de095d5dfb37774b6f521c31c5c4 100644 (file)
@@ -33,14 +33,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
index bf3d0a9c609d743b3c4a4c87661d7637ad8bd9fd..ba619916d454677c31b2a5ea1528bbb8d93da7f8 100644 (file)
@@ -543,7 +543,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++)
index 1c6eaf7cb616779858c96986a32366f7834a76a9..af62308b88f6b0a7945587ecc85c4d36441d225d 100644 (file)
@@ -250,7 +250,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);
index 604a83bd8a4cf4793871d30b2c914f571c88761d..1d4f6a18609dfc97f9a1bb44fca178fb763586ba 100644 (file)
@@ -133,7 +133,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));
 
index cd3a3b9d0f9b8a3a6a3c58a9ac22be04a5714fa9..c2e71c17d652fa3aeef91d77aee504a8e556c9f9 100644 (file)
@@ -37,6 +37,8 @@
 #include "memory.h"
 #include "log.h"
 
+#include "tests.h"
+
 extern struct thread_master *master;
 
 enum
index e5f688c21317389113df4948124af5e402933f7a..2f133cc5d46290c14aa81fdba590e11bc3b8e91d 100644 (file)
@@ -36,6 +36,8 @@
 #include "workqueue.h"
 #include <math.h>
 
+#include "tests.h"
+
 extern struct thread_master *master;
 static struct work_queue *heavy_wq;
 
index 577a4816f5a7022d346cb3bdcb2f8dc147a6309c..9af46c88f7a3e34ad664b5c9950948bd5987392d 100644 (file)
@@ -36,6 +36,8 @@
 #include "memory.h"
 #include <math.h>
 
+#include "tests.h"
+
 enum
 {
   ITERS_FIRST = 0,
index 5e7bdcb15f3fb922c43f19424ae902899fcca5a0..5396c7d50fa9725834ffc3cf115b5e4547b797f7 100644 (file)
@@ -52,7 +52,7 @@ DEFUN (daemon_exit,
 }
 
 static int timer_count;
-int
+static int
 test_timer (struct thread *thread)
 {
   int *count = THREAD_ARG(thread);
index 9672e95a1413c331a8485111dedb254561e0981c..b6741f305711638f8896143294ea72e8512252ab 100644 (file)
@@ -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 
  */
index 87692e7b6e66fda431b800145f73d5aa1a2f7ab8..1810c5f4b2a82cae5fa2185ae6898556c053b71b 100644 (file)
@@ -35,7 +35,7 @@ struct quagga_signal_t sigs[] =
 
 struct thread_master *master;
 
-int
+static int
 threadfunc (struct thread *thread)
 {
   int *null = NULL;
index d80f3900e01c18981849ba2bae2d60664dca9fe1..4a042403038b76f639f4b998ba4365e379ba89f2 100644 (file)
 #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");
index 94c8f1df255f4d0bcd2b1a6fec3a9f4c1246b9fa..47c0b7376efd1fb5a03016f64c0c150ea2746fe8 100644 (file)
@@ -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);
diff --git a/tests/tests.h b/tests/tests.h
new file mode 100644 (file)
index 0000000..a528e55
--- /dev/null
@@ -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 */