[PATCH] Fix calloc argument order

5 views
Skip to first unread message

Silvan Jegen

unread,
May 18, 2024, 5:30:41 AM5/18/24
to mbl...@googlegroups.com, Silvan Jegen
These were found through gcc warnings.
---
mflag.c | 2 +-
msort.c | 2 +-
mthread.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mflag.c b/mflag.c
index ddf633c..9ee8747 100644
--- a/mflag.c
+++ b/mflag.c
@@ -145,7 +145,7 @@ main(int argc, char *argv[])
return 0;
}

- args = calloc(sizeof (char *), argsalloc);
+ args = calloc(argsalloc, sizeof (char *));
if (!args)
exit(-1);

diff --git a/msort.c b/msort.c
index 5d2d88d..02d1e42 100644
--- a/msort.c
+++ b/msort.c
@@ -319,7 +319,7 @@ main(int argc, char *argv[])

xpledge("stdio rpath", "");

- mails = calloc(sizeof (struct mail), mailalloc);
+ mails = calloc(mailalloc, sizeof (struct mail));
if (!mails)
exit(-1);

diff --git a/mthread.c b/mthread.c
index d200879..77fb21e 100644
--- a/mthread.c
+++ b/mthread.c
@@ -365,7 +365,7 @@ sort_tree(struct container *c, int depth)
if (i == 1) // no sort needed
return;

- struct container **a = calloc(sizeof (struct container *), i);
+ struct container **a = calloc(i, sizeof (struct container *));
if (!a)
return;

--
2.45.1

Reply all
Reply to author
Forward
0 new messages