From 7802170f7c1d2b89c2610b7affddb3d1b26fc87d Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 22 May 2023 14:54:43 +0100 Subject: [PATCH] Use the %llu format specifier for uint64_t We change to use %llu when printing uint64_t types for consistency with what we've done elsewhere. Reviewed-by: Tomas Mraz Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/20914) --- ssl/quic/quic_trace.c | 77 ++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/ssl/quic/quic_trace.c b/ssl/quic/quic_trace.c index 058c0022a86a9..961de4dbd5e5d 100644 --- a/ssl/quic/quic_trace.c +++ b/ssl/quic/quic_trace.c @@ -94,16 +94,22 @@ static int frame_ack(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_ack(pkt, 0, &ack, NULL)) return 0; - BIO_printf(bio, " Largest acked: %lu\n", ack.ack_ranges[0].end); - BIO_printf(bio, " Ack delay (raw) %lu\n", ossl_time2ticks(ack.delay_time)); - BIO_printf(bio, " Ack range count: %lu\n", total_ranges - 1); - BIO_printf(bio, " First ack range: %lu\n", - ack.ack_ranges[0].end - ack.ack_ranges[0].start); + BIO_printf(bio, " Largest acked: %llu\n", + (unsigned long long)ack.ack_ranges[0].end); + BIO_printf(bio, " Ack delay (raw) %llu\n", + (unsigned long long)ossl_time2ticks(ack.delay_time)); + BIO_printf(bio, " Ack range count: %llu\n", + (unsigned long long)total_ranges - 1); + BIO_printf(bio, " First ack range: %llu\n", + (unsigned long long)(ack.ack_ranges[0].end + - ack.ack_ranges[0].start)); for (i = 1; i < total_ranges; i++) { - BIO_printf(bio, " Gap: %lu\n", - ack.ack_ranges[i - 1].start - ack.ack_ranges[i].end - 2); - BIO_printf(bio, " Ack range len: %lu\n", - ack.ack_ranges[i].end - ack.ack_ranges[i].start); + BIO_printf(bio, " Gap: %llu\n", + (unsigned long long)(ack.ack_ranges[i - 1].start + - ack.ack_ranges[i].end - 2)); + BIO_printf(bio, " Ack range len: %llu\n", + (unsigned long long)(ack.ack_ranges[i].end + - ack.ack_ranges[i].start)); } OPENSSL_free(ack_ranges); @@ -117,9 +123,12 @@ static int frame_reset_stream(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_reset_stream(pkt, &frame_data)) return 0; - BIO_printf(bio, " Stream id: %lu\n", frame_data.stream_id); - BIO_printf(bio, " App Protocol Error Code: %lu\n", frame_data.app_error_code); - BIO_printf(bio, " Final size: %lu\n", frame_data.final_size); + BIO_printf(bio, " Stream id: %llu\n", + (unsigned long long)frame_data.stream_id); + BIO_printf(bio, " App Protocol Error Code: %llu\n", + (unsigned long long)frame_data.app_error_code); + BIO_printf(bio, " Final size: %llu\n", + (unsigned long long)frame_data.final_size); return 1; } @@ -131,8 +140,10 @@ static int frame_stop_sending(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_stop_sending(pkt, &frame_data)) return 0; - BIO_printf(bio, " Stream id: %lu\n", frame_data.stream_id); - BIO_printf(bio, " App Protocol Error Code: %lu\n", frame_data.app_error_code); + BIO_printf(bio, " Stream id: %llu\n", + (unsigned long long)frame_data.stream_id); + BIO_printf(bio, " App Protocol Error Code: %llu\n", + (unsigned long long)frame_data.app_error_code); return 1; } @@ -144,8 +155,8 @@ static int frame_crypto(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_crypto(pkt, 1, &frame_data)) return 0; - BIO_printf(bio, " Offset: %lu\n", frame_data.offset); - BIO_printf(bio, " Len: %lu\n", frame_data.len); + BIO_printf(bio, " Offset: %llu\n", (unsigned long long)frame_data.offset); + BIO_printf(bio, " Len: %llu\n", (unsigned long long)frame_data.len); return 1; } @@ -211,14 +222,16 @@ static int frame_stream(BIO *bio, PACKET *pkt, uint64_t frame_type) if (!ossl_quic_wire_decode_frame_stream(pkt, 1, &frame_data)) return 0; - BIO_printf(bio, " Stream id: %lu\n", frame_data.stream_id); - BIO_printf(bio, " Offset: %lu\n", frame_data.offset); + BIO_printf(bio, " Stream id: %llu\n", + (unsigned long long)frame_data.stream_id); + BIO_printf(bio, " Offset: %llu\n", + (unsigned long long)frame_data.offset); /* * It would be nice to find a way of passing the implicit length through * to the msg_callback. But this is not currently possible. */ if (frame_data.has_explicit_len) - BIO_printf(bio, " Len: %lu\n", frame_data.len); + BIO_printf(bio, " Len: %llu\n", (unsigned long long)frame_data.len); else BIO_puts(bio, " Len: \n"); @@ -232,7 +245,7 @@ static int frame_max_data(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_max_data(pkt, &max_data)) return 0; - BIO_printf(bio, " Max Data: %lu\n", max_data); + BIO_printf(bio, " Max Data: %llu\n", (unsigned long long)max_data); return 1; } @@ -246,7 +259,8 @@ static int frame_max_stream_data(BIO *bio, PACKET *pkt) &max_stream_data)) return 0; - BIO_printf(bio, " Max Stream Data: %lu\n", max_stream_data); + BIO_printf(bio, " Max Stream Data: %llu\n", + (unsigned long long)max_stream_data); return 1; } @@ -258,7 +272,7 @@ static int frame_max_streams(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_max_streams(pkt, &max_streams)) return 0; - BIO_printf(bio, " Max Streams: %lu\n", max_streams); + BIO_printf(bio, " Max Streams: %llu\n", (unsigned long long)max_streams); return 1; } @@ -270,7 +284,7 @@ static int frame_data_blocked(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_data_blocked(pkt, &max_data)) return 0; - BIO_printf(bio, " Max Data: %lu\n", max_data); + BIO_printf(bio, " Max Data: %llu\n", (unsigned long long)max_data); return 1; } @@ -284,8 +298,8 @@ static int frame_stream_data_blocked(BIO *bio, PACKET *pkt) &max_data)) return 0; - BIO_printf(bio, " Stream id: %lu\n", stream_id); - BIO_printf(bio, " Max Data: %lu\n", max_data); + BIO_printf(bio, " Stream id: %llu\n", (unsigned long long)stream_id); + BIO_printf(bio, " Max Data: %llu\n", (unsigned long long)max_data); return 1; } @@ -297,7 +311,7 @@ static int frame_streams_blocked(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_streams_blocked(pkt, &max_data)) return 0; - BIO_printf(bio, " Max Data: %lu\n", max_data); + BIO_printf(bio, " Max Data: %llu\n", (unsigned long long)max_data); return 1; } @@ -309,8 +323,10 @@ static int frame_new_conn_id(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_new_conn_id(pkt, &frame_data)) return 0; - BIO_printf(bio, " Sequence Number: %lu\n", frame_data.seq_num); - BIO_printf(bio, " Retire prior to: %lu\n", frame_data.retire_prior_to); + BIO_printf(bio, " Sequence Number: %llu\n", + (unsigned long long)frame_data.seq_num); + BIO_printf(bio, " Retire prior to: %llu\n", + (unsigned long long)frame_data.retire_prior_to); BIO_puts(bio, " Connection id: "); put_conn_id(bio, &frame_data.conn_id); BIO_puts(bio, "\n Stateless Reset Token: "); @@ -327,7 +343,7 @@ static int frame_retire_conn_id(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_retire_conn_id(pkt, &seq_num)) return 0; - BIO_printf(bio, " Sequence Number: %lu\n", seq_num); + BIO_printf(bio, " Sequence Number: %llu\n", (unsigned long long)seq_num); return 1; } @@ -363,7 +379,8 @@ static int frame_conn_closed(BIO *bio, PACKET *pkt) if (!ossl_quic_wire_decode_frame_conn_close(pkt, &frame_data)) return 0; - BIO_printf(bio, " Error Code: %lu\n", frame_data.error_code); + BIO_printf(bio, " Error Code: %llu\n", + (unsigned long long)frame_data.error_code); BIO_puts(bio, " Reason: "); put_str(bio, frame_data.reason, frame_data.reason_len); BIO_puts(bio, "\n");