From 1555c86e5f7e3c46b4f696ed665c2f988976b81f Mon Sep 17 00:00:00 2001 From: "J.W. Jagersma" Date: Sat, 1 Oct 2022 18:41:44 +0200 Subject: [PATCH] Cast values to match printf format strings. For some reason djgpp uses '(unsigned) long int' for (u)int32_t. This causes errors with -Werror=format, even though these types are in practice identical. Obvious solution: cast to the types indicated by the format string. For asn1_time_test.c I changed the format string to %lli since time_t may be 'long long' some platforms. Reviewed-by: Hugo Landau Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/19322) --- crypto/asn1/x_int64.c | 4 ++-- ssl/ssl_ciph.c | 15 ++++++++++----- ssl/ssl_txt.c | 2 +- ssl/t1_trce.c | 2 +- test/asn1_time_test.c | 6 ++++-- test/ssl_cert_table_internal_test.c | 3 ++- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/crypto/asn1/x_int64.c b/crypto/asn1/x_int64.c index d05fe26bb0..b7251b8ad8 100644 --- a/crypto/asn1/x_int64.c +++ b/crypto/asn1/x_int64.c @@ -220,8 +220,8 @@ static int uint32_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it, int indent, const ASN1_PCTX *pctx) { if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED) - return BIO_printf(out, "%d\n", **(int32_t **)pval); - return BIO_printf(out, "%u\n", **(uint32_t **)pval); + return BIO_printf(out, "%d\n", (int)**(int32_t **)pval); + return BIO_printf(out, "%u\n", (unsigned int)**(uint32_t **)pval); } diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index 48aad6342b..8c805fbfcf 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -820,8 +820,9 @@ static void ssl_cipher_apply_rule(uint32_t cipher_id, uint32_t alg_mkey, OSSL_TRACE_BEGIN(TLS_CIPHER) { BIO_printf(trc_out, "Applying rule %d with %08x/%08x/%08x/%08x/%08x %08x (%d)\n", - rule, alg_mkey, alg_auth, alg_enc, alg_mac, min_tls, - algo_strength, strength_bits); + rule, (unsigned int)alg_mkey, (unsigned int)alg_auth, + (unsigned int)alg_enc, (unsigned int)alg_mac, min_tls, + (unsigned int)algo_strength, (int)strength_bits); } if (rule == CIPHER_DEL || rule == CIPHER_BUMP) @@ -865,9 +866,13 @@ static void ssl_cipher_apply_rule(uint32_t cipher_id, uint32_t alg_mkey, BIO_printf(trc_out, "\nName: %s:" "\nAlgo = %08x/%08x/%08x/%08x/%08x Algo_strength = %08x\n", - cp->name, cp->algorithm_mkey, cp->algorithm_auth, - cp->algorithm_enc, cp->algorithm_mac, cp->min_tls, - cp->algo_strength); + cp->name, + (unsigned int)cp->algorithm_mkey, + (unsigned int)cp->algorithm_auth, + (unsigned int)cp->algorithm_enc, + (unsigned int)cp->algorithm_mac, + cp->min_tls, + (unsigned int)cp->algo_strength); } if (cipher_id != 0 && (cipher_id != cp->id)) continue; diff --git a/ssl/ssl_txt.c b/ssl/ssl_txt.c index 68f15d6182..9e9c2e10ec 100644 --- a/ssl/ssl_txt.c +++ b/ssl/ssl_txt.c @@ -153,7 +153,7 @@ int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) if (istls13) { if (BIO_printf(bp, " Max Early Data: %u\n", - x->ext.max_early_data) <= 0) + (unsigned int)x->ext.max_early_data) <= 0) goto err; } diff --git a/ssl/t1_trce.c b/ssl/t1_trce.c index 6d314c5331..fbaa199fd5 100644 --- a/ssl/t1_trce.c +++ b/ssl/t1_trce.c @@ -906,7 +906,7 @@ static int ssl_print_extension(BIO *bio, int indent, int server, | ((unsigned int)ext[2] << 8) | (unsigned int)ext[3]; BIO_indent(bio, indent + 2, 80); - BIO_printf(bio, "max_early_data=%u\n", max_early_data); + BIO_printf(bio, "max_early_data=%u\n", (unsigned int)max_early_data); break; default: diff --git a/test/asn1_time_test.c b/test/asn1_time_test.c index b222b44091..3344b76eae 100644 --- a/test/asn1_time_test.c +++ b/test/asn1_time_test.c @@ -434,8 +434,10 @@ static int convert_asn1_to_time_t(int idx) testdateutc = ossl_asn1_string_to_time_t(asn1_to_utc[idx].input); if (!TEST_time_t_eq(testdateutc, asn1_to_utc[idx].expected)) { - TEST_info("ossl_asn1_string_to_time_t (%s) failed: expected %li, got %li\n", - asn1_to_utc[idx].input, asn1_to_utc[idx].expected, (signed long) testdateutc); + TEST_info("ossl_asn1_string_to_time_t (%s) failed: expected %lli, got %lli\n", + asn1_to_utc[idx].input, + (long long int)asn1_to_utc[idx].expected, + (long long int)testdateutc); return 0; } return 1; diff --git a/test/ssl_cert_table_internal_test.c b/test/ssl_cert_table_internal_test.c index 1dc09c013c..397834a8f1 100644 --- a/test/ssl_cert_table_internal_test.c +++ b/test/ssl_cert_table_internal_test.c @@ -35,7 +35,8 @@ static int do_test_cert_table(int nid, uint32_t amask, size_t idx, TEST_note("Expected %s, got %s\n", OBJ_nid2sn(nid), OBJ_nid2sn(clu->nid)); if (clu->amask != amask) - TEST_note("Expected auth mask 0x%x, got 0x%x\n", amask, clu->amask); + TEST_note("Expected auth mask 0x%x, got 0x%x\n", + (unsigned int)amask, (unsigned int)clu->amask); return 0; }