Browse Source

[tcp] Avoid printf format warnings on some compilers

In several places, we currently use size_t to represent a difference
between TCP sequence numbers.  This can cause compiler warnings
relating to printf format specifiers, since the result of
(uint32_t+size_t) may be an unsigned long on some compilers.

Fix by using uint32_t for all variables that represent a difference
between TCP sequence numbers.

Tested-by: Joshua Oreman <oremanj@xenon.get-linux.org>
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
5552a1b202
1 changed files with 9 additions and 9 deletions
  1. 9
    9
      src/net/tcp.c

+ 9
- 9
src/net/tcp.c View File

399
 	void *payload;
399
 	void *payload;
400
 	unsigned int flags;
400
 	unsigned int flags;
401
 	size_t len = 0;
401
 	size_t len = 0;
402
-	size_t seq_len;
403
-	size_t app_win;
404
-	size_t max_rcv_win;
402
+	uint32_t seq_len;
403
+	uint32_t app_win;
404
+	uint32_t max_rcv_win;
405
 	int rc;
405
 	int rc;
406
 
406
 
407
 	/* If retransmission timer is already running, do nothing */
407
 	/* If retransmission timer is already running, do nothing */
490
 	tcphdr->csum = tcpip_chksum ( iobuf->data, iob_len ( iobuf ) );
490
 	tcphdr->csum = tcpip_chksum ( iobuf->data, iob_len ( iobuf ) );
491
 
491
 
492
 	/* Dump header */
492
 	/* Dump header */
493
-	DBGC2 ( tcp, "TCP %p TX %d->%d %08x..%08zx           %08x %4zd",
493
+	DBGC2 ( tcp, "TCP %p TX %d->%d %08x..%08x           %08x %4zd",
494
 		tcp, ntohs ( tcphdr->src ), ntohs ( tcphdr->dest ),
494
 		tcp, ntohs ( tcphdr->src ), ntohs ( tcphdr->dest ),
495
 		ntohl ( tcphdr->seq ), ( ntohl ( tcphdr->seq ) + seq_len ),
495
 		ntohl ( tcphdr->seq ), ( ntohl ( tcphdr->seq ) + seq_len ),
496
 		ntohl ( tcphdr->ack ), len );
496
 		ntohl ( tcphdr->ack ), len );
671
  * @v tcp		TCP connection
671
  * @v tcp		TCP connection
672
  * @v seq_len		Sequence space length to consume
672
  * @v seq_len		Sequence space length to consume
673
  */
673
  */
674
-static void tcp_rx_seq ( struct tcp_connection *tcp, size_t seq_len ) {
674
+static void tcp_rx_seq ( struct tcp_connection *tcp, uint32_t seq_len ) {
675
 	tcp->rcv_ack += seq_len;
675
 	tcp->rcv_ack += seq_len;
676
 	if ( tcp->rcv_win > seq_len ) {
676
 	if ( tcp->rcv_win > seq_len ) {
677
 		tcp->rcv_win -= seq_len;
677
 		tcp->rcv_win -= seq_len;
722
  */
722
  */
723
 static int tcp_rx_ack ( struct tcp_connection *tcp, uint32_t ack,
723
 static int tcp_rx_ack ( struct tcp_connection *tcp, uint32_t ack,
724
 			uint32_t win ) {
724
 			uint32_t win ) {
725
-	size_t ack_len = ( ack - tcp->snd_seq );
725
+	uint32_t ack_len = ( ack - tcp->snd_seq );
726
 	size_t len;
726
 	size_t len;
727
 	unsigned int acked_flags;
727
 	unsigned int acked_flags;
728
 
728
 
729
 	/* Check for out-of-range or old duplicate ACKs */
729
 	/* Check for out-of-range or old duplicate ACKs */
730
 	if ( ack_len > tcp->snd_sent ) {
730
 	if ( ack_len > tcp->snd_sent ) {
731
-		DBGC ( tcp, "TCP %p received ACK for %08x..%08zx, "
731
+		DBGC ( tcp, "TCP %p received ACK for %08x..%08x, "
732
 		       "sent only %08x..%08x\n", tcp, tcp->snd_seq,
732
 		       "sent only %08x..%08x\n", tcp, tcp->snd_seq,
733
 		       ( tcp->snd_seq + ack_len ), tcp->snd_seq,
733
 		       ( tcp->snd_seq + ack_len ), tcp->snd_seq,
734
 		       ( tcp->snd_seq + tcp->snd_sent ) );
734
 		       ( tcp->snd_seq + tcp->snd_sent ) );
795
  */
795
  */
796
 static int tcp_rx_data ( struct tcp_connection *tcp, uint32_t seq,
796
 static int tcp_rx_data ( struct tcp_connection *tcp, uint32_t seq,
797
 			 struct io_buffer *iobuf ) {
797
 			 struct io_buffer *iobuf ) {
798
-	size_t already_rcvd;
799
-	size_t len;
798
+	uint32_t already_rcvd;
799
+	uint32_t len;
800
 	int rc;
800
 	int rc;
801
 
801
 
802
 	/* Ignore duplicate or out-of-order data */
802
 	/* Ignore duplicate or out-of-order data */

Loading…
Cancel
Save