]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
misc: fix reversed calloc arguments
authorDarrick J. Wong <djwong@kernel.org>
Tue, 29 Jul 2025 20:14:14 +0000 (13:14 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Fri, 8 Aug 2025 11:39:09 +0000 (13:39 +0200)
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@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
db/namei.c
libxcmd/input.c
logprint/log_misc.c
repair/phase3.c
repair/quotacheck.c

index 2586e0591c2357c1b5c7910b6bec188d845c3129..1d9581c323cd6775cb83d7093448f6d38e9c913e 100644 (file)
@@ -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;
 
index fa80e5abb224eeea02b4fd3450958cb5f1bb6b12..4092d9d06382e91e076086bc12d418fc364083d4 100644 (file)
@@ -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)
index 144695753211aa57c1d1ec8fc9f9eba426d7147a..88679e9ee1dce6c84250a838b90cf45f59a92669 100644 (file)
@@ -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;
index 3a3ca22de14d269937eb73a73f1732b800c9b514..6ec616d9b31d446ac0ddda33b09beb25acd1f132 100644 (file)
@@ -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;
index 7953144c3f416bf96d0a37ec3064d5dac709cfad..df6cde2d58aec0f604f522127b4e646412f35f7f 100644 (file)
@@ -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);