btrfs: fix kvcalloc() arguments order in btrfs_ioctl_send() 87/314887/1 accepted/tizen/unified/x/20240725.154558
authorDmitry Antipov <dmantipov@yandex.ru>
Thu, 21 Dec 2023 08:47:45 +0000 (11:47 +0300)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 22 Jul 2024 22:34:16 +0000 (07:34 +0900)
When compiling with gcc version 14.0.0 20231220 (experimental)
and W=1, I've noticed the following warning:

fs/btrfs/send.c: In function 'btrfs_ioctl_send':
fs/btrfs/send.c:8208:44: warning: 'kvcalloc' sizes specified with 'sizeof'
in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
 8208 |         sctx->clone_roots = kvcalloc(sizeof(*sctx->clone_roots),
      |                                            ^

Since 'n' and 'size' arguments of 'kvcalloc()' are multiplied to
calculate the final size, their actual order doesn't affect the result
and so this is not a bug. But it's still worth to fix it.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit 6ff09b6b8c2fb6b3edda4ffaa173153a40653067)
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Change-Id: I7df8d4188a28977c9905c2af967790f79c6635e8

fs/btrfs/send.c

index 937b60ae576e0116d26c70f4518a52888d359aba..96b5ecc0561aa2774b407fe9cd2b4597dc7da0f1 100644 (file)
@@ -7934,8 +7934,8 @@ long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg)
        sctx->rbtree_new_refs = RB_ROOT;
        sctx->rbtree_deleted_refs = RB_ROOT;
 
-       sctx->clone_roots = kvcalloc(sizeof(*sctx->clone_roots),
-                                    arg->clone_sources_count + 1,
+       sctx->clone_roots = kvcalloc(arg->clone_sources_count + 1,
+                                    sizeof(*sctx->clone_roots),
                                     GFP_KERNEL);
        if (!sctx->clone_roots) {
                ret = -ENOMEM;