Skip to content

Commit

Permalink
fix more calloc warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
q66 committed Dec 9, 2024
1 parent 9232499 commit 585617b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
20 changes: 20 additions & 0 deletions patches/src.freebsd.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@
}

Expand Down Expand Up @@ -3674,6 +3685,15 @@
#include <ctype.h>
#include <err.h>
#include <errno.h>
@@ -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 @@
Expand Down
4 changes: 2 additions & 2 deletions src.freebsd/bc/dc/bcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src.freebsd/coreutils/factor/factor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 585617b

Please sign in to comment.