From 9a40597cedaa900368234b0813b626f6889d1fd3 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Tue, 4 Jul 2017 21:31:30 +0200 Subject: [PATCH] work on -Wconversion... --- src/core/ipv4/etharp.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/core/ipv4/etharp.c b/src/core/ipv4/etharp.c index e5fdeafe..122d3e47 100644 --- a/src/core/ipv4/etharp.c +++ b/src/core/ipv4/etharp.c @@ -288,7 +288,7 @@ etharp_find_entry(const ip4_addr_t *ipaddr, u8_t flags, struct netif* netif) if ((empty == ARP_TABLE_SIZE) && (state == ETHARP_STATE_EMPTY)) { LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_find_entry: found empty entry %"U16_F"\n", (u16_t)i)); /* remember first empty entry */ - empty = i; + empty = (s8_t)i; } else if (state != ETHARP_STATE_EMPTY) { LWIP_ASSERT("state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE", state == ETHARP_STATE_PENDING || state >= ETHARP_STATE_STABLE); @@ -300,21 +300,21 @@ etharp_find_entry(const ip4_addr_t *ipaddr, u8_t flags, struct netif* netif) ) { LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: found matching entry %"U16_F"\n", (u16_t)i)); /* found exact IP address match, simply bail out */ - return i; + return (s8_t)i; } /* pending entry? */ if (state == ETHARP_STATE_PENDING) { /* pending with queued packets? */ if (arp_table[i].q != NULL) { if (arp_table[i].ctime >= age_queue) { - old_queue = i; + old_queue = (s8_t)i; age_queue = arp_table[i].ctime; } } else /* pending without queued packets? */ { if (arp_table[i].ctime >= age_pending) { - old_pending = i; + old_pending = (s8_t)i; age_pending = arp_table[i].ctime; } } @@ -327,7 +327,7 @@ etharp_find_entry(const ip4_addr_t *ipaddr, u8_t flags, struct netif* netif) { /* remember entry with oldest stable entry in oldest, its age in maxtime */ if (arp_table[i].ctime >= age_stable) { - old_stable = i; + old_stable = (s8_t)i; age_stable = arp_table[i].ctime; } } @@ -355,25 +355,25 @@ etharp_find_entry(const ip4_addr_t *ipaddr, u8_t flags, struct netif* netif) /* 1) empty entry available? */ if (empty < ARP_TABLE_SIZE) { - i = empty; + i = (u8_t)empty; LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting empty entry %"U16_F"\n", (u16_t)i)); } else { /* 2) found recyclable stable entry? */ if (old_stable < ARP_TABLE_SIZE) { /* recycle oldest stable*/ - i = old_stable; + i = (u8_t)old_stable; LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting oldest stable entry %"U16_F"\n", (u16_t)i)); /* no queued packets should exist on stable entries */ LWIP_ASSERT("arp_table[i].q == NULL", arp_table[i].q == NULL); /* 3) found recyclable pending entry without queued packets? */ } else if (old_pending < ARP_TABLE_SIZE) { /* recycle oldest pending */ - i = old_pending; + i = (u8_t)old_pending; LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting oldest pending entry %"U16_F" (without queue)\n", (u16_t)i)); /* 4) found recyclable pending entry with queued packets? */ } else if (old_queue < ARP_TABLE_SIZE) { /* recycle oldest pending (queued packets are free in etharp_free_entry) */ - i = old_queue; + i = (u8_t)old_queue; LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: selecting oldest pending entry %"U16_F", freeing packet queue %p\n", (u16_t)i, (void *)(arp_table[i].q))); /* no empty or recyclable entries found */ } else { @@ -816,7 +816,7 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr) dest = &mcastaddr; /* unicast destination IP address? */ } else { - s8_t i; + u8_t i; /* outside local network? if so, this can neither be a global broadcast nor a subnet broadcast. */ if (!ip4_addr_netcmp(ipaddr, netif_ip4_addr(netif), netif_ip4_netmask(netif)) && @@ -932,7 +932,8 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q) struct eth_addr * srcaddr = (struct eth_addr *)netif->hwaddr; err_t result = ERR_MEM; int is_new_entry = 0; - s8_t i; /* ARP entry index */ + s8_t i_err; + u8_t i; /* non-unicast address? */ if (ip4_addr_isbroadcast(ipaddr, netif) || @@ -943,17 +944,18 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q) } /* find entry in ARP cache, ask to create entry if queueing packet */ - i = etharp_find_entry(ipaddr, ETHARP_FLAG_TRY_HARD, netif); + i_err = etharp_find_entry(ipaddr, ETHARP_FLAG_TRY_HARD, netif); /* could not find or create entry? */ - if (i < 0) { + if (i_err < 0) { LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: could not create ARP entry\n")); if (q) { LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: packet dropped\n")); ETHARP_STATS_INC(etharp.memerr); } - return (err_t)i; + return (err_t)i_err; } + i = (u8_t)i_err; /* mark a fresh entry as pending (we just sent a request) */ if (arp_table[i].state == ETHARP_STATE_EMPTY) {