Skip to content

Commit 751aaf6

Browse files
committed
test code: fix wrong order in calloc call (-Wcalloc-transposed-args)
The calloc API is void* calloc(size_t num, size_t size); gcc14 added a warning when usign sizeof(.) for the first argument, e.g., calloc(sizeof(sk_t), 1) generates a warning as it likely should be calloc(1, sizeof(sk_t)). MAYO-C/apps/example.c: In function ‘example_mayo’: MAYO-C/apps/example.c:34:31: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] 34 | sk_t *esk = calloc(sizeof(sk_t), 1); This commit fixes those warnings by swapping the arguments.
1 parent cad1ed8 commit 751aaf6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

apps/example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static int example_mayo(const mayo_params_t* p) {
3131
unsigned char *sk = calloc(p->csk_bytes, 1);
3232

3333
unsigned char *epk = calloc(p->epk_bytes, 1);
34-
sk_t *esk = calloc(sizeof(sk_t), 1);
34+
sk_t *esk = calloc(1, sizeof(sk_t));
3535

3636
unsigned char *sig = calloc(p->sig_bytes + msglen, 1);
3737

test/bench.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int bench_sig(const mayo_params_t *p, int runs, int csv) {
9999
unsigned char *pk = calloc(p->cpk_bytes, 1);
100100
unsigned char *epk = calloc(p->epk_bytes, 1);
101101
unsigned char *sk = calloc(p->csk_bytes, 1);
102-
sk_t *esk = (sk_t *)calloc(sizeof(sk_t), 1);
102+
sk_t *esk = (sk_t *)calloc(1, sizeof(sk_t));
103103
unsigned char *sig = calloc(p->sig_bytes + m_len, 1);
104104
unsigned char *m = calloc(m_len, 1);
105105
unsigned long long len = p->sig_bytes;

0 commit comments

Comments
 (0)