From d8e26bc5bb99b70a075a814613928460ade48dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sun, 18 Sep 2016 22:40:48 +0200 Subject: [PATCH] Solve further asprintf() issues by sweeping them under the rug. All further instances of asprintf() or vasprintf() in our codebase are either in libcryb-test or in individual unit tests, and in all cases, the only consequence of a failed call is that the result will say "no description" instead of either a description of the test or an explanation of how it failed. Therefore, we can simply ignore the problem and cast the call to void to satisfy gcc. --- lib/test/cryb_t_main.c | 2 +- lib/test/cryb_t_malloc.c | 4 ++-- t/t_aes.c | 4 ++-- t/t_fletcher.c | 6 +++--- t/t_md2.c | 2 +- t/t_md4.c | 2 +- t/t_md5.c | 2 +- t/t_sha1.c | 2 +- t/t_sha224.c | 2 +- t/t_sha256.c | 2 +- t/t_sha384.c | 2 +- t/t_sha512.c | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/test/cryb_t_main.c b/lib/test/cryb_t_main.c index dae1658..7d10b61 100644 --- a/lib/test/cryb_t_main.c +++ b/lib/test/cryb_t_main.c @@ -120,7 +120,7 @@ t_add_test(t_func *func, void *arg, const char *fmt, ...) err(1, "malloc()"); t->func = func; va_start(ap, fmt); - vasprintf(&t->desc, fmt, ap); + (void)vasprintf(&t->desc, fmt, ap); va_end(ap); t->arg = arg; t_grow(1); diff --git a/lib/test/cryb_t_malloc.c b/lib/test/cryb_t_malloc.c index 0d3d9ea..7073de1 100644 --- a/lib/test/cryb_t_malloc.c +++ b/lib/test/cryb_t_malloc.c @@ -551,9 +551,9 @@ t_malloc_leaked(char **desc, void *arg CRYB_UNUSED) } nleaked += nmapalloc - nmapfree; if (nleaked > 0) - asprintf(desc, "%lu allocation(s) leaked", nleaked); + (void)asprintf(desc, "%lu allocation(s) leaked", nleaked); else - asprintf(desc, "%s", "no memory leaked"); + (void)asprintf(desc, "%s", "no memory leaked"); return (nleaked == 0); } diff --git a/t/t_aes.c b/t/t_aes.c index 25c8328..c9a069d 100644 --- a/t/t_aes.c +++ b/t/t_aes.c @@ -114,7 +114,7 @@ t_aes_enc(char **desc CRYB_UNUSED, void *arg) uint8_t out[AES_BLOCK_LEN]; aes_ctx ctx; - asprintf(desc, "%s (encrypt)", t->desc); + (void)asprintf(desc, "%s (encrypt)", t->desc); aes_init(&ctx, CIPHER_MODE_ENCRYPT, t->key, t->keylen / 8); aes_update(&ctx, t->ptext, AES_BLOCK_LEN, out); aes_finish(&ctx); @@ -128,7 +128,7 @@ t_aes_dec(char **desc CRYB_UNUSED, void *arg) uint8_t out[AES_BLOCK_LEN]; aes_ctx ctx; - asprintf(desc, "%s (decrypt)", t->desc); + (void)asprintf(desc, "%s (decrypt)", t->desc); aes_init(&ctx, CIPHER_MODE_DECRYPT, t->key, t->keylen / 8); aes_update(&ctx, t->ctext, AES_BLOCK_LEN, out); aes_finish(&ctx); diff --git a/t/t_fletcher.c b/t/t_fletcher.c index adae8df..5bbed7e 100644 --- a/t/t_fletcher.c +++ b/t/t_fletcher.c @@ -253,7 +253,7 @@ t_fletcher16(char **desc, void *arg) { struct t_case *t = arg; - asprintf(desc, "(16-bit) %s", t->desc); + (void)asprintf(desc, "(16-bit) %s", t->desc); return (t_compare_x16(t->sum16, fletcher16_hash(t->data, t->len))); } @@ -262,7 +262,7 @@ t_fletcher32(char **desc, void *arg) { struct t_case *t = arg; - asprintf(desc, "(32-bit) %s", t->desc); + (void)asprintf(desc, "(32-bit) %s", t->desc); return (t_compare_x32(t->sum32, fletcher32_hash(t->data, t->len))); } @@ -271,7 +271,7 @@ t_fletcher64(char **desc, void *arg) { struct t_case *t = arg; - asprintf(desc, "(64-bit) %s", t->desc); + (void)asprintf(desc, "(64-bit) %s", t->desc); return (t_compare_x64(t->sum64, fletcher64_hash(t->data, t->len))); } diff --git a/t/t_md2.c b/t/t_md2.c index dfa7336..1e57f68 100644 --- a/t/t_md2.c +++ b/t/t_md2.c @@ -184,7 +184,7 @@ t_md2_perf(char **desc, void *arg) clock_gettime(CLOCK_MONOTONIC, &te); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(desc, "%zu bytes: %d iterations in %'lu ns", + (void)asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); return (1); } diff --git a/t/t_md4.c b/t/t_md4.c index eb8995d..70000bf 100644 --- a/t/t_md4.c +++ b/t/t_md4.c @@ -200,7 +200,7 @@ t_md4_perf(char **desc, void *arg) clock_gettime(CLOCK_MONOTONIC, &te); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(desc, "%zu bytes: %d iterations in %'lu ns", + (void)asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); return (1); } diff --git a/t/t_md5.c b/t/t_md5.c index c4252c7..121174c 100644 --- a/t/t_md5.c +++ b/t/t_md5.c @@ -200,7 +200,7 @@ t_md5_perf(char **desc, void *arg) clock_gettime(CLOCK_MONOTONIC, &te); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(desc, "%zu bytes: %d iterations in %'lu ns", + (void)asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); return (1); } diff --git a/t/t_sha1.c b/t/t_sha1.c index fd121c4..04afc37 100644 --- a/t/t_sha1.c +++ b/t/t_sha1.c @@ -193,7 +193,7 @@ t_sha1_perf(char **desc, void *arg) clock_gettime(CLOCK_MONOTONIC, &te); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(desc, "%zu bytes: %d iterations in %'lu ns", + (void)asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); return (1); } diff --git a/t/t_sha224.c b/t/t_sha224.c index 7c92a4c..bd8e835 100644 --- a/t/t_sha224.c +++ b/t/t_sha224.c @@ -202,7 +202,7 @@ t_sha224_perf(char **desc, void *arg) clock_gettime(CLOCK_MONOTONIC, &te); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(desc, "%zu bytes: %d iterations in %'lu ns", + (void)asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); return (1); } diff --git a/t/t_sha256.c b/t/t_sha256.c index 767ae40..35067c1 100644 --- a/t/t_sha256.c +++ b/t/t_sha256.c @@ -198,7 +198,7 @@ t_sha256_perf(char **desc, void *arg) clock_gettime(CLOCK_MONOTONIC, &te); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(desc, "%zu bytes: %d iterations in %'lu ns", + (void)asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); return (1); } diff --git a/t/t_sha384.c b/t/t_sha384.c index 5003df9..c57da43 100644 --- a/t/t_sha384.c +++ b/t/t_sha384.c @@ -214,7 +214,7 @@ t_sha384_perf(char **desc, void *arg) clock_gettime(CLOCK_MONOTONIC, &te); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(desc, "%zu bytes: %d iterations in %'lu ns", + (void)asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); return (1); } diff --git a/t/t_sha512.c b/t/t_sha512.c index 1c25c82..6a55273 100644 --- a/t/t_sha512.c +++ b/t/t_sha512.c @@ -224,7 +224,7 @@ t_sha512_perf(char **desc, void *arg) clock_gettime(CLOCK_MONOTONIC, &te); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(desc, "%zu bytes: %d iterations in %'lu ns", + (void)asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); return (1); }