mirror of
https://github.com/cryb-to/cryb-to.git
synced 2024-12-21 20:11:08 +00:00
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.
This commit is contained in:
parent
eab216c06a
commit
d8e26bc5bb
12 changed files with 16 additions and 16 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue