mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-03-17 01:21:12 +00:00
bug #26523: Compiler Warnings
This commit is contained in:
parent
426dd9bfad
commit
dbcce3a4be
@ -1315,6 +1315,7 @@ do_dns_found(const char *name, struct ip_addr *ipaddr, void *arg)
|
|||||||
struct dns_api_msg *msg = (struct dns_api_msg*)arg;
|
struct dns_api_msg *msg = (struct dns_api_msg*)arg;
|
||||||
|
|
||||||
LWIP_ASSERT("DNS response for wrong host name", strcmp(msg->name, name) == 0);
|
LWIP_ASSERT("DNS response for wrong host name", strcmp(msg->name, name) == 0);
|
||||||
|
LWIP_UNUSED_ARG(name);
|
||||||
|
|
||||||
if (ipaddr == NULL) {
|
if (ipaddr == NULL) {
|
||||||
/* timeout or memory error */
|
/* timeout or memory error */
|
||||||
|
@ -315,7 +315,7 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
|||||||
sa->sin_addr.s_addr = addr.addr;
|
sa->sin_addr.s_addr = addr.addr;
|
||||||
sa->sin_family = AF_INET;
|
sa->sin_family = AF_INET;
|
||||||
sa->sin_len = sizeof(struct sockaddr_in);
|
sa->sin_len = sizeof(struct sockaddr_in);
|
||||||
sa->sin_port = htons(port_nr);
|
sa->sin_port = htons((u16_t)port_nr);
|
||||||
|
|
||||||
/* set up addrinfo */
|
/* set up addrinfo */
|
||||||
ai->ai_family = AF_INET;
|
ai->ai_family = AF_INET;
|
||||||
|
@ -318,7 +318,7 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
|||||||
* In that case, newconn->socket is counted down (newconn->socket--),
|
* In that case, newconn->socket is counted down (newconn->socket--),
|
||||||
* so nsock->rcvevent is >= 1 here!
|
* so nsock->rcvevent is >= 1 here!
|
||||||
*/
|
*/
|
||||||
nsock->rcvevent += -1 - newconn->socket;
|
nsock->rcvevent += (s16_t)(-1 - newconn->socket);
|
||||||
newconn->socket = newsock;
|
newconn->socket = newsock;
|
||||||
sys_sem_signal(socksem);
|
sys_sem_signal(socksem);
|
||||||
|
|
||||||
@ -455,14 +455,9 @@ lwip_listen(int s, int backlog)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* limit the "backlog" parameter to fit in an u8_t */
|
/* limit the "backlog" parameter to fit in an u8_t */
|
||||||
if (backlog < 0) {
|
backlog = LWIP_MIN(LWIP_MAX(backlog, 0), 0xff);
|
||||||
backlog = 0;
|
|
||||||
}
|
|
||||||
if (backlog > 0xff) {
|
|
||||||
backlog = 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = netconn_listen_with_backlog(sock->conn, backlog);
|
err = netconn_listen_with_backlog(sock->conn, (u8_t)backlog);
|
||||||
|
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err));
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err));
|
||||||
@ -1557,7 +1552,7 @@ int
|
|||||||
lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
|
lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
|
||||||
{
|
{
|
||||||
struct lwip_socket *sock = get_socket(s);
|
struct lwip_socket *sock = get_socket(s);
|
||||||
int err = ERR_OK;
|
err_t err = ERR_OK;
|
||||||
struct lwip_setgetsockopt_data data;
|
struct lwip_setgetsockopt_data data;
|
||||||
|
|
||||||
if (!sock)
|
if (!sock)
|
||||||
@ -1901,21 +1896,21 @@ lwip_setsockopt_internal(void *arg)
|
|||||||
case IPPROTO_UDPLITE:
|
case IPPROTO_UDPLITE:
|
||||||
switch (optname) {
|
switch (optname) {
|
||||||
case UDPLITE_SEND_CSCOV:
|
case UDPLITE_SEND_CSCOV:
|
||||||
if ((*(int*)optval != 0) && (*(int*)optval < 8)) {
|
if ((*(int*)optval != 0) && ((*(int*)optval < 8)) || (*(int*)optval > 0xffff)) {
|
||||||
/* don't allow illegal values! */
|
/* don't allow illegal values! */
|
||||||
sock->conn->pcb.udp->chksum_len_tx = 8;
|
sock->conn->pcb.udp->chksum_len_tx = 8;
|
||||||
} else {
|
} else {
|
||||||
sock->conn->pcb.udp->chksum_len_tx = *(int*)optval;
|
sock->conn->pcb.udp->chksum_len_tx = (u16_t)*(int*)optval;
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) -> %d\n",
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV) -> %d\n",
|
||||||
s, (*(int*)optval)) );
|
s, (*(int*)optval)) );
|
||||||
break;
|
break;
|
||||||
case UDPLITE_RECV_CSCOV:
|
case UDPLITE_RECV_CSCOV:
|
||||||
if ((*(int*)optval != 0) && (*(int*)optval < 8)) {
|
if ((*(int*)optval != 0) && ((*(int*)optval < 8)) || (*(int*)optval > 0xffff)) {
|
||||||
/* don't allow illegal values! */
|
/* don't allow illegal values! */
|
||||||
sock->conn->pcb.udp->chksum_len_rx = 8;
|
sock->conn->pcb.udp->chksum_len_rx = 8;
|
||||||
} else {
|
} else {
|
||||||
sock->conn->pcb.udp->chksum_len_rx = *(int*)optval;
|
sock->conn->pcb.udp->chksum_len_rx = (u16_t)*(int*)optval;
|
||||||
}
|
}
|
||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %d\n",
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %d\n",
|
||||||
s, (*(int*)optval)) );
|
s, (*(int*)optval)) );
|
||||||
|
@ -282,7 +282,9 @@ dhcp_select(struct netif *netif)
|
|||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
p = (const char*)netif->hostname;
|
p = (const char*)netif->hostname;
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, strlen(p));
|
u8_t namelen = (u8_t)strlen(p);
|
||||||
|
LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
|
||||||
|
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
|
||||||
while (*p) {
|
while (*p) {
|
||||||
dhcp_option_byte(dhcp, *p++);
|
dhcp_option_byte(dhcp, *p++);
|
||||||
}
|
}
|
||||||
@ -990,7 +992,9 @@ dhcp_renew(struct netif *netif)
|
|||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
p = (const char*)netif->hostname;
|
p = (const char*)netif->hostname;
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, strlen(p));
|
u8_t namelen = (u8_t)strlen(p);
|
||||||
|
LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
|
||||||
|
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
|
||||||
while (*p) {
|
while (*p) {
|
||||||
dhcp_option_byte(dhcp, *p++);
|
dhcp_option_byte(dhcp, *p++);
|
||||||
}
|
}
|
||||||
@ -1056,7 +1060,9 @@ dhcp_rebind(struct netif *netif)
|
|||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
p = (const char*)netif->hostname;
|
p = (const char*)netif->hostname;
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, strlen(p));
|
u8_t namelen = (u8_t)strlen(p);
|
||||||
|
LWIP_ASSERT("DHCP: hostname is too long!", namelen < 255);
|
||||||
|
dhcp_option(dhcp, DHCP_OPTION_HOSTNAME, namelen);
|
||||||
while (*p) {
|
while (*p) {
|
||||||
dhcp_option_byte(dhcp, *p++);
|
dhcp_option_byte(dhcp, *p++);
|
||||||
}
|
}
|
||||||
|
@ -625,7 +625,7 @@ dns_send(u8_t numdns, const char* name, u8_t id)
|
|||||||
MEMCPY( query, &qry, SIZEOF_DNS_QUERY);
|
MEMCPY( query, &qry, SIZEOF_DNS_QUERY);
|
||||||
|
|
||||||
/* resize pbuf to the exact dns query */
|
/* resize pbuf to the exact dns query */
|
||||||
pbuf_realloc(p, (query + SIZEOF_DNS_QUERY) - ((char*)(p->payload)));
|
pbuf_realloc(p, (u16_t)((query + SIZEOF_DNS_QUERY) - ((char*)(p->payload))));
|
||||||
|
|
||||||
/* connect to the server for faster receiving */
|
/* connect to the server for faster receiving */
|
||||||
udp_connect(dns_pcb, &dns_servers[numdns], DNS_SERVER_PORT);
|
udp_connect(dns_pcb, &dns_servers[numdns], DNS_SERVER_PORT);
|
||||||
@ -741,12 +741,12 @@ dns_check_entries(void)
|
|||||||
static void
|
static void
|
||||||
dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
|
dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port)
|
||||||
{
|
{
|
||||||
u8_t i;
|
u16_t i;
|
||||||
char *pHostname;
|
char *pHostname;
|
||||||
struct dns_hdr *hdr;
|
struct dns_hdr *hdr;
|
||||||
struct dns_answer ans;
|
struct dns_answer ans;
|
||||||
struct dns_table_entry *pEntry;
|
struct dns_table_entry *pEntry;
|
||||||
u8_t nquestions, nanswers;
|
u16_t nquestions, nanswers;
|
||||||
#if (DNS_USES_STATIC_BUF == 0)
|
#if (DNS_USES_STATIC_BUF == 0)
|
||||||
u8_t dns_payload[DNS_MSG_SIZE];
|
u8_t dns_payload[DNS_MSG_SIZE];
|
||||||
#endif /* (DNS_USES_STATIC_BUF == 0) */
|
#endif /* (DNS_USES_STATIC_BUF == 0) */
|
||||||
|
@ -181,7 +181,7 @@ lwip_standard_chksum(void *dataptr, int len)
|
|||||||
sum = SWAP_BYTES_IN_WORD(sum);
|
sum = SWAP_BYTES_IN_WORD(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return (u16_t)sum;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ lwip_standard_chksum(void *dataptr, int len)
|
|||||||
sum = SWAP_BYTES_IN_WORD(sum);
|
sum = SWAP_BYTES_IN_WORD(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return (u16_t)sum;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -155,7 +155,8 @@ ip_reass_tmr(void)
|
|||||||
static int
|
static int
|
||||||
ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev)
|
ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev)
|
||||||
{
|
{
|
||||||
int pbufs_freed = 0;
|
u16_t pbufs_freed = 0;
|
||||||
|
u8_t clen;
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
struct ip_reass_helper *iprh;
|
struct ip_reass_helper *iprh;
|
||||||
|
|
||||||
@ -175,7 +176,9 @@ ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *p
|
|||||||
/* Then, copy the original header into it. */
|
/* Then, copy the original header into it. */
|
||||||
SMEMCPY(p->payload, &ipr->iphdr, IP_HLEN);
|
SMEMCPY(p->payload, &ipr->iphdr, IP_HLEN);
|
||||||
icmp_time_exceeded(p, ICMP_TE_FRAG);
|
icmp_time_exceeded(p, ICMP_TE_FRAG);
|
||||||
pbufs_freed += pbuf_clen(p);
|
clen = pbuf_clen(p);
|
||||||
|
LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff);
|
||||||
|
pbufs_freed += clen;
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_ICMP */
|
#endif /* LWIP_ICMP */
|
||||||
@ -189,8 +192,10 @@ ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *p
|
|||||||
pcur = p;
|
pcur = p;
|
||||||
/* get the next pointer before freeing */
|
/* get the next pointer before freeing */
|
||||||
p = iprh->next_pbuf;
|
p = iprh->next_pbuf;
|
||||||
pbufs_freed += pbuf_clen(pcur);
|
clen = pbuf_clen(pcur);
|
||||||
pbuf_free(pcur);
|
LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff);
|
||||||
|
pbufs_freed += clen;
|
||||||
|
pbuf_free(pcur);
|
||||||
}
|
}
|
||||||
/* Then, unchain the struct ip_reassdata from the list and free it. */
|
/* Then, unchain the struct ip_reassdata from the list and free it. */
|
||||||
ip_reass_dequeue_datagram(ipr, prev);
|
ip_reass_dequeue_datagram(ipr, prev);
|
||||||
|
@ -234,10 +234,10 @@ snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap)
|
|||||||
/* lookup current source address for this dst */
|
/* lookup current source address for this dst */
|
||||||
dst_if = ip_route(&td->dip);
|
dst_if = ip_route(&td->dip);
|
||||||
dst_ip.addr = ntohl(dst_if->ip_addr.addr);
|
dst_ip.addr = ntohl(dst_if->ip_addr.addr);
|
||||||
trap_msg.sip_raw[0] = dst_ip.addr >> 24;
|
trap_msg.sip_raw[0] = (u8_t)(dst_ip.addr >> 24);
|
||||||
trap_msg.sip_raw[1] = dst_ip.addr >> 16;
|
trap_msg.sip_raw[1] = (u8_t)(dst_ip.addr >> 16);
|
||||||
trap_msg.sip_raw[2] = dst_ip.addr >> 8;
|
trap_msg.sip_raw[2] = (u8_t)(dst_ip.addr >> 8);
|
||||||
trap_msg.sip_raw[3] = dst_ip.addr;
|
trap_msg.sip_raw[3] = (u8_t)dst_ip.addr;
|
||||||
trap_msg.gen_trap = generic_trap;
|
trap_msg.gen_trap = generic_trap;
|
||||||
trap_msg.spc_trap = specific_trap;
|
trap_msg.spc_trap = specific_trap;
|
||||||
if (generic_trap == SNMP_GENTRAP_ENTERPRISESPC)
|
if (generic_trap == SNMP_GENTRAP_ENTERPRISESPC)
|
||||||
|
@ -422,7 +422,9 @@ u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb)
|
|||||||
pcb->rcv_ann_wnd = 0;
|
pcb->rcv_ann_wnd = 0;
|
||||||
} else {
|
} else {
|
||||||
/* keep the right edge of window constant */
|
/* keep the right edge of window constant */
|
||||||
pcb->rcv_ann_wnd = pcb->rcv_ann_right_edge - pcb->rcv_nxt;
|
u32_t new_rcv_ann_wnd = pcb->rcv_ann_right_edge - pcb->rcv_nxt;
|
||||||
|
LWIP_ASSERT("new_rcv_ann_wnd <= 0xffff", new_rcv_ann_wnd <= 0xffff);
|
||||||
|
pcb->rcv_ann_wnd = (u16_t)new_rcv_ann_wnd;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
static void tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb);
|
static void tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb);
|
||||||
|
|
||||||
static struct tcp_hdr *
|
static struct tcp_hdr *
|
||||||
tcp_output_set_header(struct tcp_pcb *pcb, struct pbuf *p, int optlen,
|
tcp_output_set_header(struct tcp_pcb *pcb, struct pbuf *p, u16_t optlen,
|
||||||
u32_t seqno_be /* already in network byte order */)
|
u32_t seqno_be /* already in network byte order */)
|
||||||
{
|
{
|
||||||
struct tcp_hdr *tcphdr = p->payload;
|
struct tcp_hdr *tcphdr = p->payload;
|
||||||
|
@ -57,7 +57,7 @@ tcp_create_segment(struct ip_addr* src_ip, struct ip_addr* dst_ip,
|
|||||||
struct pbuf* p;
|
struct pbuf* p;
|
||||||
struct ip_hdr* iphdr;
|
struct ip_hdr* iphdr;
|
||||||
struct tcp_hdr* tcphdr;
|
struct tcp_hdr* tcphdr;
|
||||||
u16_t pbuf_len = sizeof(struct ip_hdr) + sizeof(struct tcp_hdr) + data_len;
|
u16_t pbuf_len = (u16_t)(sizeof(struct ip_hdr) + sizeof(struct tcp_hdr) + data_len);
|
||||||
|
|
||||||
p = pbuf_alloc(PBUF_RAW, pbuf_len, PBUF_POOL);
|
p = pbuf_alloc(PBUF_RAW, pbuf_len, PBUF_POOL);
|
||||||
EXPECT_RETNULL(p != NULL);
|
EXPECT_RETNULL(p != NULL);
|
||||||
@ -82,7 +82,7 @@ tcp_create_segment(struct ip_addr* src_ip, struct ip_addr* dst_ip,
|
|||||||
tcphdr->ackno = htonl(ackno);
|
tcphdr->ackno = htonl(ackno);
|
||||||
TCPH_HDRLEN_SET(tcphdr, sizeof(struct tcp_hdr)/4);
|
TCPH_HDRLEN_SET(tcphdr, sizeof(struct tcp_hdr)/4);
|
||||||
TCPH_FLAGS_SET(tcphdr, headerflags);
|
TCPH_FLAGS_SET(tcphdr, headerflags);
|
||||||
tcphdr->wnd = htonl(TCP_WND);
|
tcphdr->wnd = htons(TCP_WND);
|
||||||
|
|
||||||
/* copy data */
|
/* copy data */
|
||||||
memcpy((char*)tcphdr + sizeof(struct tcp_hdr), data, data_len);
|
memcpy((char*)tcphdr + sizeof(struct tcp_hdr), data, data_len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user