From f9965b49672a8c3afef6b82a135b48ce143d2959 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Thu, 23 Apr 2015 08:44:44 +0200 Subject: [PATCH] some more compiler warning fixes --- src/api/sockets.c | 47 +++++++++++++++++++------------------- src/include/netif/etharp.h | 20 ++++++++-------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/api/sockets.c b/src/api/sockets.c index 0d92ebd4..04a2a295 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -499,28 +499,6 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) /* Prevent automatic window updates, we do this on our own! */ netconn_set_noautorecved(newconn, 1); - /* Note that POSIX only requires us to check addr is non-NULL. addrlen must - * not be NULL if addr is valid. - */ - if (addr != NULL) { - union sockaddr_aligned tempaddr; - /* get the IP address and port of the remote host */ - err = netconn_peer(newconn, &naddr, &port); - if (err != ERR_OK) { - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_peer failed, err=%d\n", s, err)); - netconn_delete(newconn); - sock_set_errno(sock, err_to_errno(err)); - return -1; - } - LWIP_ASSERT("addr valid but addrlen NULL", addrlen != NULL); - - IPADDR_PORT_TO_SOCKADDR(&tempaddr, &naddr, port); - if (*addrlen > tempaddr.sa.sa_len) { - *addrlen = tempaddr.sa.sa_len; - } - MEMCPY(addr, &tempaddr, *addrlen); - } - newsock = alloc_socket(newconn, 1); if (newsock == -1) { netconn_delete(newconn); @@ -541,11 +519,32 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) newconn->socket = newsock; SYS_ARCH_UNPROTECT(lev); - LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d", s, newsock)); + /* Note that POSIX only requires us to check addr is non-NULL. addrlen must + * not be NULL if addr is valid. + */ if (addr != NULL) { - LWIP_DEBUGF(SOCKETS_DEBUG, (" addr=")); + union sockaddr_aligned tempaddr; + /* get the IP address and port of the remote host */ + err = netconn_peer(newconn, &naddr, &port); + if (err != ERR_OK) { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d): netconn_peer failed, err=%d\n", s, err)); + netconn_delete(newconn); + sock_set_errno(sock, err_to_errno(err)); + return -1; + } + LWIP_ASSERT("addr valid but addrlen NULL", addrlen != NULL); + + IPADDR_PORT_TO_SOCKADDR(&tempaddr, &naddr, port); + if (*addrlen > tempaddr.sa.sa_len) { + *addrlen = tempaddr.sa.sa_len; + } + MEMCPY(addr, &tempaddr, *addrlen); + + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock)); ip_addr_debug_print_val(SOCKETS_DEBUG, naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F"\n", port)); + } else { + LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d", s, newsock)); } sock_set_errno(sock, 0); diff --git a/src/include/netif/etharp.h b/src/include/netif/etharp.h index 8752c089..3f895455 100644 --- a/src/include/netif/etharp.h +++ b/src/include/netif/etharp.h @@ -123,6 +123,16 @@ PACK_STRUCT_END #define ETHTYPE_PTP 0x88F7U /* Precision time protocol */ #define ETHTYPE_QINQ 0x9100U /* Q-in-Q, 802.1ad */ +/** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) + * to a filter function that returns the correct netif when using multiple + * netifs on one hardware interface where the netif's low-level receive + * routine cannot decide for the correct netif (e.g. when mapping multiple + * IP addresses to one hardware interface). + */ +#ifndef LWIP_ARP_FILTER_NETIF +#define LWIP_ARP_FILTER_NETIF 0 +#endif + #if LWIP_IPV4 && LWIP_ARP /* don't build if not configured for use in lwipopts.h */ #ifdef PACK_STRUCT_USE_INCLUDES @@ -174,16 +184,6 @@ PACK_STRUCT_END #define ARP_REQUEST 1 #define ARP_REPLY 2 -/** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) - * to a filter function that returns the correct netif when using multiple - * netifs on one hardware interface where the netif's low-level receive - * routine cannot decide for the correct netif (e.g. when mapping multiple - * IP addresses to one hardware interface). - */ -#ifndef LWIP_ARP_FILTER_NETIF -#define LWIP_ARP_FILTER_NETIF 0 -#endif - #if ARP_QUEUEING /** struct for queueing outgoing packets for unknown address * defined here to be accessed by memp.h