From 0f2c6c8f70cc4d1feaab7cd7d22899274885a751 Mon Sep 17 00:00:00 2001
From: Erik Ekman <erik.ekman@verisure.com>
Date: Thu, 28 May 2015 15:06:20 +0200
Subject: [PATCH 5/6] test_etharp: Fix warnings about incompatible pointer type

Fix lots of these:

In file included from ../../../../lwip/test/unit/etharp/test_etharp.c:4:0:
../../../../lwip/src/include/netif/etharp.h:199:6: note: expected 'const
struct ip4_addr_t **' but argument is of type 'struct ip4_addr_t **'
  s8_t etharp_find_addr(struct netif *netif, const ip4_addr_t *ipaddr,
       ^
../../../../lwip/test/unit/etharp/test_etharp.c:253:5: warning:
passing argument 4 of 'etharp_find_addr' from incompatible pointer type [enabled by default]
    idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
          ^
---
 test/unit/etharp/test_etharp.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/test/unit/etharp/test_etharp.c b/test/unit/etharp/test_etharp.c
index be5a1b4..f985ab0 100644
--- a/test/unit/etharp/test_etharp.c
+++ b/test/unit/etharp/test_etharp.c
@@ -127,6 +127,12 @@ etharp_teardown(void)
   default_netif_remove();
 }
 
+/* Wrapper to add const casts to fix warnings */
+static s8_t find_addr(struct netif *netif, ip4_addr_t *ipaddr, struct eth_addr **eth_ret, ip4_addr_t **ip_ret)
+{
+  return etharp_find_addr(netif, (const ip4_addr_t *) ipaddr, eth_ret, (const ip4_addr_t **) ip_ret);
+}
+
 
 /* Test functions */
 
@@ -174,7 +180,7 @@ START_TEST(test_etharp_table)
         /* queued UDP packet sent? */
         fail_unless(linkoutput_ctr == (2*i) + 2);
 
-        idx = etharp_find_addr(NULL, &adrs[i], &unused_ethaddr, &unused_ipaddr);
+        idx = find_addr(NULL, &adrs[i], &unused_ethaddr, &unused_ipaddr);
         fail_unless(idx == i);
         etharp_tmr();
       }
@@ -184,7 +190,7 @@ START_TEST(test_etharp_table)
     /* create one static entry */
     err = etharp_add_static_entry(&adrs[ARP_TABLE_SIZE], &test_ethaddr3);
     fail_unless(err == ERR_OK);
-    idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
+    idx = find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
     fail_unless(idx == 0);
     fail_unless(linkoutput_ctr == 0);
 #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
@@ -209,7 +215,7 @@ START_TEST(test_etharp_table)
         /* queued UDP packet sent? */
         fail_unless(linkoutput_ctr == (2*i) + 2);
 
-        idx = etharp_find_addr(NULL, &adrs[i], &unused_ethaddr, &unused_ipaddr);
+        idx = find_addr(NULL, &adrs[i], &unused_ethaddr, &unused_ipaddr);
         if (i < ARP_TABLE_SIZE - 1) {
           fail_unless(idx == i+1);
         } else {
@@ -223,31 +229,31 @@ START_TEST(test_etharp_table)
     /* create a second static entry */
     err = etharp_add_static_entry(&adrs[ARP_TABLE_SIZE+1], &test_ethaddr4);
     fail_unless(err == ERR_OK);
-    idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
+    idx = find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
     fail_unless(idx == 0);
-    idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr);
+    idx = find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr);
     fail_unless(idx == 2);
     /* and remove it again */
     err = etharp_remove_static_entry(&adrs[ARP_TABLE_SIZE+1]);
     fail_unless(err == ERR_OK);
-    idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
+    idx = find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
     fail_unless(idx == 0);
-    idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr);
+    idx = find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr);
     fail_unless(idx == -1);
 #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
 
     /* check that static entries don't time out */
     etharp_remove_all();
-    idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
+    idx = find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
     fail_unless(idx == 0);
 
 #if ETHARP_SUPPORT_STATIC_ENTRIES
     /* remove the first static entry */
     err = etharp_remove_static_entry(&adrs[ARP_TABLE_SIZE]);
     fail_unless(err == ERR_OK);
-    idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
+    idx = find_addr(NULL, &adrs[ARP_TABLE_SIZE], &unused_ethaddr, &unused_ipaddr);
     fail_unless(idx == -1);
-    idx = etharp_find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr);
+    idx = find_addr(NULL, &adrs[ARP_TABLE_SIZE+1], &unused_ethaddr, &unused_ipaddr);
     fail_unless(idx == -1);
 #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
 
-- 
2.3.6

