Pārlūkot izejas kodu

[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 gadus atpakaļ
vecāks
revīzija
5552a1b202
1 mainītis faili ar 9 papildinājumiem un 9 dzēšanām
  1. 9
    9
      src/net/tcp.c

+ 9
- 9
src/net/tcp.c Parādīt failu

@@ -399,9 +399,9 @@ static int tcp_xmit ( struct tcp_connection *tcp, int force_send ) {
399 399
 	void *payload;
400 400
 	unsigned int flags;
401 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 405
 	int rc;
406 406
 
407 407
 	/* If retransmission timer is already running, do nothing */
@@ -490,7 +490,7 @@ static int tcp_xmit ( struct tcp_connection *tcp, int force_send ) {
490 490
 	tcphdr->csum = tcpip_chksum ( iobuf->data, iob_len ( iobuf ) );
491 491
 
492 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 494
 		tcp, ntohs ( tcphdr->src ), ntohs ( tcphdr->dest ),
495 495
 		ntohl ( tcphdr->seq ), ( ntohl ( tcphdr->seq ) + seq_len ),
496 496
 		ntohl ( tcphdr->ack ), len );
@@ -671,7 +671,7 @@ static void tcp_rx_opts ( struct tcp_connection *tcp, const void *data,
671 671
  * @v tcp		TCP connection
672 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 675
 	tcp->rcv_ack += seq_len;
676 676
 	if ( tcp->rcv_win > seq_len ) {
677 677
 		tcp->rcv_win -= seq_len;
@@ -722,13 +722,13 @@ static int tcp_rx_syn ( struct tcp_connection *tcp, uint32_t seq,
722 722
  */
723 723
 static int tcp_rx_ack ( struct tcp_connection *tcp, uint32_t ack,
724 724
 			uint32_t win ) {
725
-	size_t ack_len = ( ack - tcp->snd_seq );
725
+	uint32_t ack_len = ( ack - tcp->snd_seq );
726 726
 	size_t len;
727 727
 	unsigned int acked_flags;
728 728
 
729 729
 	/* Check for out-of-range or old duplicate ACKs */
730 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 732
 		       "sent only %08x..%08x\n", tcp, tcp->snd_seq,
733 733
 		       ( tcp->snd_seq + ack_len ), tcp->snd_seq,
734 734
 		       ( tcp->snd_seq + tcp->snd_sent ) );
@@ -795,8 +795,8 @@ static int tcp_rx_ack ( struct tcp_connection *tcp, uint32_t ack,
795 795
  */
796 796
 static int tcp_rx_data ( struct tcp_connection *tcp, uint32_t seq,
797 797
 			 struct io_buffer *iobuf ) {
798
-	size_t already_rcvd;
799
-	size_t len;
798
+	uint32_t already_rcvd;
799
+	uint32_t len;
800 800
 	int rc;
801 801
 
802 802
 	/* Ignore duplicate or out-of-order data */

Notiek ielāde…
Atcelt
Saglabāt