diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index bb2db529..3cbfb084 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -694,7 +694,7 @@ tcp_process(struct tcp_pcb *pcb) LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: Connection RESET\n")); LWIP_ASSERT("tcp_input: pcb->state != CLOSED", pcb->state != CLOSED); recv_flags |= TF_RESET; - pcb->flags &= (tcpflags_t)~(unsigned int)TF_ACK_DELAY; + pcb->flags &= ~TF_ACK_DELAY; return ERR_RST; } else { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %"U32_F" rcv_nxt %"U32_F"\n", @@ -1062,7 +1062,7 @@ tcp_receive(struct tcp_pcb *pcb) in fast retransmit. Also reset the congestion window to the slow start threshold. */ if (pcb->flags & TF_INFR) { - pcb->flags &= (tcpflags_t)~(unsigned int)TF_INFR; + pcb->flags &= ~TF_INFR; pcb->cwnd = pcb->ssthresh; } @@ -1338,7 +1338,7 @@ tcp_receive(struct tcp_pcb *pcb) if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { /* Must remove the FIN from the header as we're trimming * that byte of sequence-space from the packet */ - TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) & (tcpflags_t)~(unsigned int)TCP_FIN); + TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) & ~(unsigned int)TCP_FIN); } /* Adjust length of segment to fit in the window. */ inseg.len = pcb->rcv_wnd; @@ -1593,7 +1593,7 @@ tcp_receive(struct tcp_pcb *pcb) if (TCPH_FLAGS(next->next->tcphdr) & TCP_FIN) { /* Must remove the FIN from the header as we're trimming * that byte of sequence-space from the packet */ - TCPH_FLAGS_SET(next->next->tcphdr, TCPH_FLAGS(next->next->tcphdr) & (tcpflags_t)~(unsigned int)TCP_FIN); + TCPH_FLAGS_SET(next->next->tcphdr, TCPH_FLAGS(next->next->tcphdr) & ~TCP_FIN); } /* Adjust length of segment to fit in the window. */ next->next->len = (u16_t)(pcb->rcv_nxt + pcb->rcv_wnd - seqno); diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index 589ef5dd..ec42164b 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -1112,7 +1112,7 @@ tcp_output(struct tcp_pcb *pcb) } #endif /* TCP_OVERSIZE */ - pcb->flags &= (tcpflags_t)~(unsigned int)TF_NAGLEMEMERR; + pcb->flags &= ~TF_NAGLEMEMERR; return ERR_OK; } diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index 69c39de1..a9099d51 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -189,16 +189,16 @@ struct tcp_pcb { u16_t remote_port; tcpflags_t flags; -#define TF_ACK_DELAY ((tcpflags_t)0x0001U) /* Delayed ACK. */ -#define TF_ACK_NOW ((tcpflags_t)0x0002U) /* Immediate ACK. */ -#define TF_INFR ((tcpflags_t)0x0004U) /* In fast recovery. */ -#define TF_TIMESTAMP ((tcpflags_t)0x0008U) /* Timestamp option enabled */ -#define TF_RXCLOSED ((tcpflags_t)0x0010U) /* rx closed by tcp_shutdown */ -#define TF_FIN ((tcpflags_t)0x0020U) /* Connection was closed locally (FIN segment enqueued). */ -#define TF_NODELAY ((tcpflags_t)0x0040U) /* Disable Nagle algorithm */ -#define TF_NAGLEMEMERR ((tcpflags_t)0x0080U) /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */ +#define TF_ACK_DELAY 0x01U /* Delayed ACK. */ +#define TF_ACK_NOW 0x02U /* Immediate ACK. */ +#define TF_INFR 0x04U /* In fast recovery. */ +#define TF_TIMESTAMP 0x08U /* Timestamp option enabled */ +#define TF_RXCLOSED 0x10U /* rx closed by tcp_shutdown */ +#define TF_FIN 0x20U /* Connection was closed locally (FIN segment enqueued). */ +#define TF_NODELAY 0x40U /* Disable Nagle algorithm */ +#define TF_NAGLEMEMERR 0x80U /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */ #if LWIP_WND_SCALE -#define TF_WND_SCALE ((tcpflags_t)0x0100U) /* Window Scale option enabled */ +#define TF_WND_SCALE 0x0100U /* Window Scale option enabled */ #endif /* the rest of the fields are in host byte order @@ -351,7 +351,7 @@ void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err); #define tcp_sndbuf(pcb) ((pcb)->snd_buf) #define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen) #define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY) -#define tcp_nagle_enable(pcb) ((pcb)->flags &= (tcpflags_t)~(unsigned int)TF_NODELAY) +#define tcp_nagle_enable(pcb) ((pcb)->flags &= ~TF_NODELAY) #define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) #if TCP_LISTEN_BACKLOG diff --git a/src/include/lwip/tcp_impl.h b/src/include/lwip/tcp_impl.h index 1ddfcadb..b02b054c 100644 --- a/src/include/lwip/tcp_impl.h +++ b/src/include/lwip/tcp_impl.h @@ -182,7 +182,7 @@ PACK_STRUCT_END #define TCPH_FLAGS(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS) #define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr)) -#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS((u16_t)(~(unsigned int)(TCP_FLAGS)))) | htons(flags)) +#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS(~TCP_FLAGS)) | htons(flags)) #define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags)) #define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags)) @@ -460,7 +460,7 @@ struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); #define tcp_ack(pcb) \ do { \ if((pcb)->flags & TF_ACK_DELAY) { \ - (pcb)->flags &= (tcpflags_t)~(unsigned int)TF_ACK_DELAY; \ + (pcb)->flags &= ~TF_ACK_DELAY; \ (pcb)->flags |= TF_ACK_NOW; \ } \ else { \