Skip to content

Commit

Permalink
Use the %llu format specifier for uint64_t
Browse files Browse the repository at this point in the history
We change to use %llu when printing uint64_t types for consistency with
what we've done elsewhere.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #20914)
  • Loading branch information
mattcaswell committed May 24, 2023
1 parent 5cf99b4 commit 7802170
Showing 1 changed file with 47 additions and 30 deletions.
77 changes: 47 additions & 30 deletions ssl/quic/quic_trace.c
Expand Up @@ -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);
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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: <implicit length>\n");

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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: ");
Expand All @@ -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;
}
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 7802170

Please sign in to comment.