lwip corrected coverity and compiler warnings

Coverity ids: 1373147 and 1374442.
pull/4284/head
Mika Leppänen 2017-05-05 08:46:45 +03:00
parent 053139b85d
commit 55753be8ef
2 changed files with 14 additions and 3 deletions

View File

@ -27,9 +27,14 @@ EthernetInterface::EthernetInterface()
nsapi_error_t EthernetInterface::set_network(const char *ip_address, const char *netmask, const char *gateway)
{
_dhcp = false;
strncpy(_ip_address, ip_address ? ip_address : "", sizeof(_ip_address));
_ip_address[sizeof(_ip_address) - 1] = '\0';
strncpy(_netmask, netmask ? netmask : "", sizeof(_netmask));
_netmask[sizeof(_netmask) - 1] = '\0';
strncpy(_gateway, gateway ? gateway : "", sizeof(_gateway));
_gateway[sizeof(_gateway) - 1] = '\0';
return NSAPI_ERROR_OK;
}

View File

@ -109,7 +109,9 @@ static void mbed_lwip_socket_callback(struct netconn *nc, enum netconn_evt eh, u
/* TCP/IP and Network Interface Initialisation */
static struct netif lwip_netif;
#if LWIP_IPV4
static bool lwip_dhcp = false;
#endif
static char lwip_mac_address[NSAPI_MAC_SIZE];
#if !LWIP_IPV4 || !LWIP_IPV6
@ -190,7 +192,9 @@ static bool convert_lwip_addr_to_mbed(nsapi_addr_t *out, const ip_addr_t *in)
return true;
}
#endif
#if LWIP_IPV6 && LWIP_IPV4
return false;
#endif
}
static const ip_addr_t *mbed_lwip_get_ipv4_addr(const struct netif *netif)
@ -325,13 +329,13 @@ static void mbed_lwip_netif_status_irq(struct netif *lwip_netif)
static void mbed_lwip_set_mac_address(void)
{
#if (MBED_MAC_ADDRESS_SUM != MBED_MAC_ADDR_INTERFACE)
snprintf(lwip_mac_address, NSAPI_MAC_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x",
(void) snprintf(lwip_mac_address, NSAPI_MAC_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x",
MBED_MAC_ADDR_0, MBED_MAC_ADDR_1, MBED_MAC_ADDR_2,
MBED_MAC_ADDR_3, MBED_MAC_ADDR_4, MBED_MAC_ADDR_5);
#else
char mac[6];
mbed_mac_address(mac);
snprintf(lwip_mac_address, NSAPI_MAC_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x",
(void) snprintf(lwip_mac_address, NSAPI_MAC_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
#endif
@ -366,7 +370,9 @@ char *mbed_lwip_get_ip_address(char *buf, nsapi_size_t buflen)
return ip4addr_ntoa_r(ip_2_ip4(addr), buf, buflen);
}
#endif
#if LWIP_IPV6 && LWIP_IPV4
return NULL;
#endif
}
const char *mbed_lwip_get_netmask(char *buf, nsapi_size_t buflen)
@ -676,7 +682,7 @@ static nsapi_error_t mbed_lwip_socket_open(nsapi_stack_t *stack, nsapi_socket_t
return NSAPI_ERROR_NO_SOCKET;
}
u8_t lwip_proto = proto == NSAPI_TCP ? NETCONN_TCP : NETCONN_UDP;
enum netconn_type lwip_proto = proto == NSAPI_TCP ? NETCONN_TCP : NETCONN_UDP;
#if LWIP_IPV6 && LWIP_IPV4
const ip_addr_t *ip_addr;