Skip to content

Commit

Permalink
btrfs: fix kvcalloc() arguments order in btrfs_ioctl_send()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
(cherry picked from commit 6ff09b6)
Signed-off-by: Emil Renner Berthing <[email protected]>
  • Loading branch information
dmantipov authored and esmil committed Aug 29, 2024
1 parent 58763dc commit a8028be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/btrfs/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -8214,8 +8214,8 @@ long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg)
goto out;
}

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;
Expand Down

0 comments on commit a8028be

Please sign in to comment.