From da6d39ebc917ef8c6873bb153264874dffec5793 Mon Sep 17 00:00:00 2001 From: Sergio Arroutbi Date: Fri, 24 Mar 2023 15:17:29 +0100 Subject: [PATCH] Fix test compilation warnings Resolves: #116 Signed-off-by: Sergio Arroutbi --- tests/alg_encr.c | 9 ++++++--- tests/api_b64.c | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/alg_encr.c b/tests/alg_encr.c index 5adf1891..ab7dfb61 100644 --- a/tests/alg_encr.c +++ b/tests/alg_encr.c @@ -64,9 +64,12 @@ test(const jose_hook_alg_t *a, const char *pt, json_t *cek, bool iter) assert(d); if (iter) { - uint8_t *xxx = ebuf; - for (size_t i = 0; i < elen; i++) - assert(d->feed(d, &xxx[i], 1)); + if (elen) { + uint8_t *xxx = ebuf; + for (size_t i = 0; i < elen; i++) { + assert(d->feed(d, &xxx[i], 1)); + } + } } else { assert(d->feed(d, ebuf, elen)); } diff --git a/tests/api_b64.c b/tests/api_b64.c index 027e7bfe..2e447398 100644 --- a/tests/api_b64.c +++ b/tests/api_b64.c @@ -62,6 +62,7 @@ main(int argc, char *argv[]) for (uint16_t i = 0; i <= UINT8_MAX; i++) { union encoding enc = { i }; uint8_t dec[3] = {}; + assert(dec != NULL); assert(jose_b64_dec_buf(enc.enc, 1, dec, sizeof(dec)) == SIZE_MAX); } @@ -74,6 +75,7 @@ main(int argc, char *argv[]) for (uint16_t i = 0; i <= UINT8_MAX; i++) { uint8_t dec[3] = { i }; union encoding enc = {}; + assert(dec != NULL); assert(jose_b64_enc_buf(dec, 1, enc.enc, sizeof(enc.enc)) == 2); set(val, enc.idx); } @@ -106,6 +108,7 @@ main(int argc, char *argv[]) for (uint16_t j = 0; j <= UINT8_MAX; j++) { uint8_t dec[3] = { i, j }; union encoding enc = {}; + assert(dec != NULL); assert(jose_b64_enc_buf(dec, 2, enc.enc, sizeof(enc.enc)) == 3); set(val, enc.idx); }