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 <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19322)
This commit is contained in:
J.W. Jagersma 2022-10-01 18:41:44 +02:00 committed by Hugo Landau
parent 43086b1bd4
commit 1555c86e5f
6 changed files with 20 additions and 12 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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:

View File

@ -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;

View File

@ -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;
}