From 6ab46f9bcd27152a8b76a94ae345fc34686e9f56 Mon Sep 17 00:00:00 2001 From: Spencer Wilson Date: Mon, 22 Jan 2024 14:19:25 -0500 Subject: [PATCH] Fix int / size_t comparison --- tests/kat_kem.c | 6 +++--- tests/kat_sig.c | 6 +++--- tests/test_helpers.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/kat_kem.c b/tests/kat_kem.c index a858868590..314b20b510 100644 --- a/tests/kat_kem.c +++ b/tests/kat_kem.c @@ -33,7 +33,7 @@ static OQS_STATUS kem_kat(const char *method_name, bool all) { uint8_t *shared_secret_d = NULL; OQS_STATUS rc, ret = OQS_ERROR; int rv; - int max_count; + size_t max_count; OQS_KAT_PRNG *prng; prng = OQS_KAT_PRNG_new(method_name); @@ -67,8 +67,8 @@ static OQS_STATUS kem_kat(const char *method_name, bool all) { max_count = all ? prng->max_kats : 1; - for (int count = 0; count < max_count; ++count) { - fprintf(fh, "count = %d\n", count); + for (size_t count = 0; count < max_count; ++count) { + fprintf(fh, "count = %zu\n", count); OQS_randombytes(seed, 48); OQS_fprintBstr(fh, "seed = ", seed, 48); diff --git a/tests/kat_sig.c b/tests/kat_sig.c index 89e1f27e2b..9a3542cf49 100644 --- a/tests/kat_sig.c +++ b/tests/kat_sig.c @@ -244,7 +244,7 @@ OQS_STATUS sig_kat(const char *method_name, bool all) { size_t signed_msg_len = 0; OQS_STATUS rc, ret = OQS_ERROR; OQS_KAT_PRNG *prng = NULL; - int max_count; + size_t max_count; prng = OQS_KAT_PRNG_new(method_name); if (prng == NULL) { @@ -277,8 +277,8 @@ OQS_STATUS sig_kat(const char *method_name, bool all) { goto err; } - for (int count = 0; count < max_count; ++count) { - fprintf(fh, "count = %d\n", count); + for (size_t count = 0; count < max_count; ++count) { + fprintf(fh, "count = %zu\n", count); OQS_randombytes(seed, 48); OQS_fprintBstr(fh, "seed = ", seed, 48); diff --git a/tests/test_helpers.h b/tests/test_helpers.h index 4dfffb61db..5b1c17d7bc 100644 --- a/tests/test_helpers.h +++ b/tests/test_helpers.h @@ -14,7 +14,7 @@ typedef union { } OQS_KAT_PRNG_state; typedef struct { - int max_kats; + size_t max_kats; OQS_KAT_PRNG_state saved_state; // The caller should use the OQS_KAT_PRNG_* functions instead of these callbacks. void (*seed)(const uint8_t *, const uint8_t *);