mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-06-13 08:23:56 +08:00
bug #28659: Missing casts
This commit is contained in:
@@ -603,7 +603,7 @@ dhcp_start(struct netif *netif)
|
||||
/* no DHCP client attached yet? */
|
||||
if (dhcp == NULL) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): starting new DHCP client\n"));
|
||||
dhcp = mem_malloc(sizeof(struct dhcp));
|
||||
dhcp = (struct dhcp *)mem_malloc(sizeof(struct dhcp));
|
||||
if (dhcp == NULL) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): could not allocate dhcp\n"));
|
||||
return ERR_MEM;
|
||||
@@ -667,7 +667,7 @@ dhcp_inform(struct netif *netif)
|
||||
{
|
||||
struct dhcp *dhcp, *old_dhcp;
|
||||
err_t result = ERR_OK;
|
||||
dhcp = mem_malloc(sizeof(struct dhcp));
|
||||
dhcp = (struct dhcp *)mem_malloc(sizeof(struct dhcp));
|
||||
if (dhcp == NULL) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("dhcp_inform(): could not allocate dhcp\n"));
|
||||
return;
|
||||
@@ -1313,7 +1313,7 @@ dhcp_unfold_reply(struct dhcp *dhcp, struct pbuf *p)
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
dhcp->msg_in = mem_malloc(sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN);
|
||||
dhcp->msg_in = (struct dhcp_msg *)mem_malloc(sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN);
|
||||
if (dhcp->msg_in == NULL) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS,
|
||||
("dhcp_unfold_reply(): could not allocate dhcp->msg_in\n"));
|
||||
|
||||
@@ -90,7 +90,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
snmp_inc_icmpinmsgs();
|
||||
|
||||
|
||||
iphdr = p->payload;
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
hlen = IPH_HL(iphdr) * 4;
|
||||
if (pbuf_header(p, -hlen) || (p->tot_len < sizeof(u16_t)*2)) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len));
|
||||
@@ -163,7 +163,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
LWIP_ASSERT("icmp_input: copying to new pbuf failed\n", 0);
|
||||
goto memerr;
|
||||
}
|
||||
iphdr = r->payload;
|
||||
iphdr = (struct ip_hdr *)r->payload;
|
||||
/* switch r->payload back to icmp header */
|
||||
if (pbuf_header(r, -hlen)) {
|
||||
LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0);
|
||||
@@ -184,7 +184,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
/* At this point, all checks are OK. */
|
||||
/* We generate an answer by switching the dest and src ip addresses,
|
||||
* setting the icmp type to ECHO_RESPONSE and updating the checksum. */
|
||||
iecho = p->payload;
|
||||
iecho = (struct icmp_echo_hdr *)p->payload;
|
||||
tmpaddr.addr = iphdr->src.addr;
|
||||
iphdr->src.addr = iphdr->dest.addr;
|
||||
iphdr->dest.addr = tmpaddr.addr;
|
||||
@@ -299,14 +299,14 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
|
||||
LWIP_ASSERT("check that first pbuf can hold icmp message",
|
||||
(q->len >= (sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE)));
|
||||
|
||||
iphdr = p->payload;
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from "));
|
||||
ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src));
|
||||
LWIP_DEBUGF(ICMP_DEBUG, (" to "));
|
||||
ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest));
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("\n"));
|
||||
|
||||
icmphdr = q->payload;
|
||||
icmphdr = (struct icmp_echo_hdr *)q->payload;
|
||||
icmphdr->type = type;
|
||||
icmphdr->code = code;
|
||||
icmphdr->id = 0;
|
||||
|
||||
@@ -200,7 +200,7 @@ ip_input(struct pbuf *p, struct netif *inp)
|
||||
snmp_inc_ipinreceives();
|
||||
|
||||
/* identify the IP header */
|
||||
iphdr = p->payload;
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
if (IPH_V(iphdr) != 4) {
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IP packet dropped due to bad version number %"U16_F"\n", IPH_V(iphdr)));
|
||||
ip_debug_print(p);
|
||||
@@ -549,7 +549,7 @@ err_t ip_output_if_opt(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest
|
||||
return ERR_BUF;
|
||||
}
|
||||
|
||||
iphdr = p->payload;
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
LWIP_ASSERT("check that first pbuf can hold struct ip_hdr",
|
||||
(p->len >= sizeof(struct ip_hdr)));
|
||||
|
||||
@@ -575,7 +575,7 @@ err_t ip_output_if_opt(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest
|
||||
#endif
|
||||
} else {
|
||||
/* IP header already included in p */
|
||||
iphdr = p->payload;
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
dest = &(iphdr->dest);
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ mem_init(void)
|
||||
(SIZEOF_STRUCT_MEM & (MEM_ALIGNMENT-1)) == 0);
|
||||
|
||||
/* align the heap */
|
||||
ram = LWIP_MEM_ALIGN(LWIP_RAM_HEAP_POINTER);
|
||||
ram = (u8_t *)LWIP_MEM_ALIGN(LWIP_RAM_HEAP_POINTER);
|
||||
/* initialize the start of the heap */
|
||||
mem = (struct mem *)ram;
|
||||
mem->next = MEM_SIZE_ALIGNED;
|
||||
|
||||
@@ -292,7 +292,7 @@ memp_init(void)
|
||||
}
|
||||
|
||||
#if !MEMP_SEPARATE_POOLS
|
||||
memp = LWIP_MEM_ALIGN(memp_memory);
|
||||
memp = (struct memp *)LWIP_MEM_ALIGN(memp_memory);
|
||||
#endif /* !MEMP_SEPARATE_POOLS */
|
||||
/* for every pool: */
|
||||
for (i = 0; i < MEMP_MAX; ++i) {
|
||||
|
||||
@@ -211,7 +211,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
||||
switch (type) {
|
||||
case PBUF_POOL:
|
||||
/* allocate head of pbuf chain into p */
|
||||
p = memp_malloc(MEMP_PBUF_POOL);
|
||||
p = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL);
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc: allocated pbuf %p\n", (void *)p));
|
||||
if (p == NULL) {
|
||||
PBUF_POOL_IS_EMPTY();
|
||||
@@ -244,7 +244,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
||||
rem_len = length - p->len;
|
||||
/* any remaining pbufs to be allocated? */
|
||||
while (rem_len > 0) {
|
||||
q = memp_malloc(MEMP_PBUF_POOL);
|
||||
q = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL);
|
||||
if (q == NULL) {
|
||||
PBUF_POOL_IS_EMPTY();
|
||||
/* free chain so far allocated */
|
||||
@@ -298,7 +298,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
||||
/* pbuf references existing (externally allocated) RAM payload? */
|
||||
case PBUF_REF:
|
||||
/* only allocate memory for the pbuf structure */
|
||||
p = memp_malloc(MEMP_PBUF);
|
||||
p = (struct pbuf *)memp_malloc(MEMP_PBUF);
|
||||
if (p == NULL) {
|
||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
|
||||
("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n",
|
||||
@@ -383,7 +383,7 @@ pbuf_realloc(struct pbuf *p, u16_t new_len)
|
||||
/* (other types merely adjust their length fields */
|
||||
if ((q->type == PBUF_RAM) && (rem_len != q->len)) {
|
||||
/* reallocate and adjust the length of the pbuf that will be split */
|
||||
q = mem_realloc(q, (u8_t *)q->payload - (u8_t *)q + rem_len);
|
||||
q = (struct pbuf *)mem_realloc(q, (u8_t *)q->payload - (u8_t *)q + rem_len);
|
||||
LWIP_ASSERT("mem_realloc give q == NULL", q != NULL);
|
||||
}
|
||||
/* adjust length fields for new last pbuf */
|
||||
|
||||
@@ -83,7 +83,7 @@ raw_input(struct pbuf *p, struct netif *inp)
|
||||
|
||||
LWIP_UNUSED_ARG(inp);
|
||||
|
||||
iphdr = p->payload;
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
proto = IPH_PROTO(iphdr);
|
||||
|
||||
prev = NULL;
|
||||
@@ -336,7 +336,7 @@ raw_new(u8_t proto)
|
||||
|
||||
LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_new\n"));
|
||||
|
||||
pcb = memp_malloc(MEMP_RAW_PCB);
|
||||
pcb = (struct raw_pcb *)memp_malloc(MEMP_RAW_PCB);
|
||||
/* could allocate RAW PCB? */
|
||||
if (pcb != NULL) {
|
||||
/* initialize PCB to all zeroes */
|
||||
|
||||
@@ -376,7 +376,7 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog)
|
||||
if (pcb->state == LISTEN) {
|
||||
return pcb;
|
||||
}
|
||||
lpcb = memp_malloc(MEMP_TCP_PCB_LISTEN);
|
||||
lpcb = (struct tcp_pcb_listen *)memp_malloc(MEMP_TCP_PCB_LISTEN);
|
||||
if (lpcb == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -914,7 +914,7 @@ tcp_seg_copy(struct tcp_seg *seg)
|
||||
{
|
||||
struct tcp_seg *cseg;
|
||||
|
||||
cseg = memp_malloc(MEMP_TCP_SEG);
|
||||
cseg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG);
|
||||
if (cseg == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -1015,19 +1015,19 @@ tcp_alloc(u8_t prio)
|
||||
struct tcp_pcb *pcb;
|
||||
u32_t iss;
|
||||
|
||||
pcb = memp_malloc(MEMP_TCP_PCB);
|
||||
pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);
|
||||
if (pcb == NULL) {
|
||||
/* Try killing oldest connection in TIME-WAIT. */
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n"));
|
||||
tcp_kill_timewait();
|
||||
/* Try to allocate a tcp_pcb again. */
|
||||
pcb = memp_malloc(MEMP_TCP_PCB);
|
||||
pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);
|
||||
if (pcb == NULL) {
|
||||
/* Try killing active connections with lower priority than the new one. */
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing connection with prio lower than %d\n", prio));
|
||||
tcp_kill_prio(prio);
|
||||
/* Try to allocate a tcp_pcb again. */
|
||||
pcb = memp_malloc(MEMP_TCP_PCB);
|
||||
pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB);
|
||||
if (pcb != NULL) {
|
||||
/* adjust err stats: memp_malloc failed twice before */
|
||||
MEMP_STATS_DEC(err, MEMP_TCP_PCB);
|
||||
|
||||
@@ -102,7 +102,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
||||
TCP_STATS_INC(tcp.recv);
|
||||
snmp_inc_tcpinsegs();
|
||||
|
||||
iphdr = p->payload;
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);
|
||||
|
||||
#if TCP_INPUT_DEBUG
|
||||
|
||||
@@ -63,7 +63,7 @@ static struct tcp_hdr *
|
||||
tcp_output_set_header(struct tcp_pcb *pcb, struct pbuf *p, u16_t optlen,
|
||||
u32_t seqno_be /* already in network byte order */)
|
||||
{
|
||||
struct tcp_hdr *tcphdr = p->payload;
|
||||
struct tcp_hdr *tcphdr = (struct tcp_hdr *)p->payload;
|
||||
tcphdr->src = htons(pcb->local_port);
|
||||
tcphdr->dest = htons(pcb->remote_port);
|
||||
tcphdr->seqno = seqno_be;
|
||||
@@ -218,7 +218,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
||||
seglen = left > (pcb->mss - optlen) ? (pcb->mss - optlen) : left;
|
||||
|
||||
/* Allocate memory for tcp_seg, and fill in fields. */
|
||||
seg = memp_malloc(MEMP_TCP_SEG);
|
||||
seg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG);
|
||||
if (seg == NULL) {
|
||||
LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SERIOUS,
|
||||
("tcp_enqueue: could not allocate memory for tcp_seg\n"));
|
||||
@@ -308,7 +308,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
||||
TCP_STATS_INC(tcp.err);
|
||||
goto memerr;
|
||||
}
|
||||
seg->tcphdr = seg->p->payload;
|
||||
seg->tcphdr = (struct tcp_hdr *)seg->p->payload;
|
||||
seg->tcphdr->src = htons(pcb->local_port);
|
||||
seg->tcphdr->dest = htons(pcb->remote_port);
|
||||
seg->tcphdr->seqno = htonl(seqno);
|
||||
@@ -781,7 +781,7 @@ tcp_rst(u32_t seqno, u32_t ackno,
|
||||
LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr",
|
||||
(p->len >= sizeof(struct tcp_hdr)));
|
||||
|
||||
tcphdr = p->payload;
|
||||
tcphdr = (struct tcp_hdr *)p->payload;
|
||||
tcphdr->src = htons(local_port);
|
||||
tcphdr->dest = htons(remote_port);
|
||||
tcphdr->seqno = htonl(seqno);
|
||||
|
||||
@@ -263,7 +263,7 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
|
||||
{
|
||||
struct sys_timeo *timeout, *t;
|
||||
|
||||
timeout = memp_malloc(MEMP_SYS_TIMEOUT);
|
||||
timeout = (struct sys_timeo *)memp_malloc(MEMP_SYS_TIMEOUT);
|
||||
if (timeout == NULL) {
|
||||
LWIP_ASSERT("sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty", timeout != NULL);
|
||||
return;
|
||||
|
||||
@@ -96,7 +96,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
||||
|
||||
UDP_STATS_INC(udp.recv);
|
||||
|
||||
iphdr = p->payload;
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
|
||||
/* Check minimum length (IP header + UDP header)
|
||||
* and move payload pointer to UDP header */
|
||||
@@ -450,7 +450,7 @@ udp_sendto_if(struct udp_pcb *pcb, struct pbuf *p,
|
||||
LWIP_ASSERT("check that first pbuf can hold struct udp_hdr",
|
||||
(q->len >= sizeof(struct udp_hdr)));
|
||||
/* q now represents the packet to be sent */
|
||||
udphdr = q->payload;
|
||||
udphdr = (struct udp_hdr *)q->payload;
|
||||
udphdr->src = htons(pcb->local_port);
|
||||
udphdr->dest = htons(dst_port);
|
||||
/* in UDP, 0 checksum means 'no checksum' */
|
||||
@@ -809,7 +809,7 @@ struct udp_pcb *
|
||||
udp_new(void)
|
||||
{
|
||||
struct udp_pcb *pcb;
|
||||
pcb = memp_malloc(MEMP_UDP_PCB);
|
||||
pcb = (struct udp_pcb *)memp_malloc(MEMP_UDP_PCB);
|
||||
/* could allocate UDP PCB? */
|
||||
if (pcb != NULL) {
|
||||
/* UDP Lite: by initializing to all zeroes, chksum_len is set to 0
|
||||
|
||||
Reference in New Issue
Block a user