[PATCH 1/1] misc: fix reversed calloc arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

gcc 14 complains about reversed arguments to calloc:

namei.c: In function ‘path_parse’:
namei.c:51:32: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
   51 |         dirpath = calloc(sizeof(*dirpath), 1);
      |                                ^
namei.c:51:32: note: earlier argument should specify number of elements, later size of each element

Fix all of these.

Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
---
 db/namei.c          |    2 +-
 libxcmd/input.c     |    2 +-
 logprint/log_misc.c |    2 +-
 repair/phase3.c     |    2 +-
 repair/quotacheck.c |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)


diff --git a/db/namei.c b/db/namei.c
index 2586e0591c2357..1d9581c323cd67 100644
--- a/db/namei.c
+++ b/db/namei.c
@@ -48,7 +48,7 @@ path_parse(
 	const char	*p = path;
 	const char	*endp = path + strlen(path);
 
-	dirpath = calloc(sizeof(*dirpath), 1);
+	dirpath = calloc(1, sizeof(*dirpath));
 	if (!dirpath)
 		return NULL;
 
diff --git a/libxcmd/input.c b/libxcmd/input.c
index fa80e5abb224ee..4092d9d06382e9 100644
--- a/libxcmd/input.c
+++ b/libxcmd/input.c
@@ -90,7 +90,7 @@ breakline(
 {
 	int	c = 0;
 	char	*p;
-	char	**rval = calloc(sizeof(char *), 1);
+	char	**rval = calloc(1, sizeof(char *));
 
 	while (rval && (p = strsep(&input, " ")) != NULL) {
 		if (!*p)
diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index 144695753211aa..88679e9ee1dce6 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -140,7 +140,7 @@ xlog_print_add_to_trans(xlog_tid_t	tid,
 {
     xlog_split_item_t *item;
 
-    item	  = (xlog_split_item_t *)calloc(sizeof(xlog_split_item_t), 1);
+    item	  = (xlog_split_item_t *)calloc(1, sizeof(xlog_split_item_t));
     item->si_xtid  = tid;
     item->si_skip = skip;
     item->si_next = split_list;
diff --git a/repair/phase3.c b/repair/phase3.c
index 3a3ca22de14d26..6ec616d9b31d44 100644
--- a/repair/phase3.c
+++ b/repair/phase3.c
@@ -150,7 +150,7 @@ phase3(
 	do_log(_("        - process newly discovered inodes...\n"));
 	set_progress_msg(PROG_FMT_NEW_INODES, (uint64_t) glob_agcount);
 
-	counts = calloc(sizeof(*counts), mp->m_sb.sb_agcount);
+	counts = calloc(mp->m_sb.sb_agcount, sizeof(*counts));
 	if (!counts) {
 		do_abort(_("no memory for uncertain inode counts\n"));
 		return;
diff --git a/repair/quotacheck.c b/repair/quotacheck.c
index 7953144c3f416b..df6cde2d58aec0 100644
--- a/repair/quotacheck.c
+++ b/repair/quotacheck.c
@@ -116,7 +116,7 @@ qc_rec_get(
 	pthread_mutex_lock(&dquots->lock);
 	node = avl64_find(&dquots->tree, id);
 	if (!node && can_alloc) {
-		qrec = calloc(sizeof(struct qc_rec), 1);
+		qrec = calloc(1, sizeof(struct qc_rec));
 		if (qrec) {
 			qrec->id = id;
 			node = avl64_insert(&dquots->tree, &qrec->node);





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux