From 585617b3ffc610c800239f29b3936802a33fee91 Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 9 Dec 2024 01:05:14 +0100 Subject: [PATCH] fix more calloc warnings --- patches/src.freebsd.patch | 20 ++++++++++++++++++++ src.freebsd/bc/dc/bcode.c | 4 ++-- src.freebsd/coreutils/factor/factor.c | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/patches/src.freebsd.patch b/patches/src.freebsd.patch index 48611c1..19c46ed 100644 --- a/patches/src.freebsd.patch +++ b/patches/src.freebsd.patch @@ -246,6 +246,17 @@ { 'e', print_err }, { 'f', print_stack }, { 'i', set_ibase }, +@@ -242,8 +242,8 @@ + stack_init(&bmachine.reg[i]); + + bmachine.readstack_sz = READSTACK_SIZE; +- bmachine.readstack = calloc(sizeof(struct source), +- bmachine.readstack_sz); ++ bmachine.readstack = calloc(bmachine.readstack_sz, ++ sizeof(struct source)); + if (bmachine.readstack == NULL) + err(1, NULL); + bmachine.obase = bmachine.ibase = 10; @@ -549,7 +549,7 @@ } @@ -3674,6 +3685,15 @@ #include #include #include +@@ -98,7 +99,7 @@ + + #define BN_CTX int + #define BN_CTX_new() NULL +-#define BN_new() ((BIGNUM *)calloc(sizeof(BIGNUM), 1)) ++#define BN_new() ((BIGNUM *)calloc(1, sizeof(BIGNUM))) + #define BN_is_zero(v) (*(v) == 0) + #define BN_is_one(v) (*(v) == 1) + #define BN_mod_word(a, b) (*(a) % (b)) --- src.orig/coreutils/fmt/fmt.c +++ src.freebsd/coreutils/fmt/fmt.c @@ -183,6 +183,7 @@ diff --git a/src.freebsd/bc/dc/bcode.c b/src.freebsd/bc/dc/bcode.c index 7ee8415..32abff0 100644 --- a/src.freebsd/bc/dc/bcode.c +++ b/src.freebsd/bc/dc/bcode.c @@ -242,8 +242,8 @@ init_bmachine(bool extended_registers) stack_init(&bmachine.reg[i]); bmachine.readstack_sz = READSTACK_SIZE; - bmachine.readstack = calloc(sizeof(struct source), - bmachine.readstack_sz); + bmachine.readstack = calloc(bmachine.readstack_sz, + sizeof(struct source)); if (bmachine.readstack == NULL) err(1, NULL); bmachine.obase = bmachine.ibase = 10; diff --git a/src.freebsd/coreutils/factor/factor.c b/src.freebsd/coreutils/factor/factor.c index 634ef72..9159bf6 100644 --- a/src.freebsd/coreutils/factor/factor.c +++ b/src.freebsd/coreutils/factor/factor.c @@ -99,7 +99,7 @@ typedef u_long BN_ULONG; #define BN_CTX int #define BN_CTX_new() NULL -#define BN_new() ((BIGNUM *)calloc(sizeof(BIGNUM), 1)) +#define BN_new() ((BIGNUM *)calloc(1, sizeof(BIGNUM))) #define BN_is_zero(v) (*(v) == 0) #define BN_is_one(v) (*(v) == 1) #define BN_mod_word(a, b) (*(a) % (b))