* [PATCH] btrfs: send: Silence build warning about kvcalloc()
@ 2024-01-08 4:13 Tiezhu Yang
2024-01-08 17:41 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Tiezhu Yang @ 2024-01-08 4:13 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba
Cc: Denis Efremov, linux-btrfs, linux-kernel
There exist the following warning when building kernel v6.7:
CC fs/btrfs/send.o
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),
| ^
fs/btrfs/send.c:8208:44: note: earlier argument should specify number of elements, later size of each element
tested with the latest upstream toolchains (20240105):
[fedora@linux 6.7.test]$ gcc --version
gcc (GCC) 14.0.0 20240105 (experimental)
[fedora@linux 6.7.test]$ as --version
GNU assembler (GNU Binutils) 2.41.50.20240105
[fedora@linux 6.7.test]$ ld --version
GNU ld (GNU Binutils) 2.41.50.20240105
just switch the first and second arguments of kvcalloc() to silence
the build warning, compile tested only.
Fixes: bae12df966f0 ("btrfs: use kvcalloc for allocation in btrfs_ioctl_send()")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
fs/btrfs/send.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 4e36550618e5..2d7519a6ce72 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -8205,8 +8205,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;
--
2.42.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] btrfs: send: Silence build warning about kvcalloc()
2024-01-08 4:13 [PATCH] btrfs: send: Silence build warning about kvcalloc() Tiezhu Yang
@ 2024-01-08 17:41 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2024-01-08 17:41 UTC (permalink / raw)
To: Tiezhu Yang
Cc: Chris Mason, Josef Bacik, David Sterba, Denis Efremov,
linux-btrfs, linux-kernel
On Mon, Jan 08, 2024 at 12:13:51PM +0800, Tiezhu Yang wrote:
> There exist the following warning when building kernel v6.7:
>
> CC fs/btrfs/send.o
> 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),
> | ^
> fs/btrfs/send.c:8208:44: note: earlier argument should specify number of elements, later size of each element
>
> tested with the latest upstream toolchains (20240105):
>
> [fedora@linux 6.7.test]$ gcc --version
> gcc (GCC) 14.0.0 20240105 (experimental)
> [fedora@linux 6.7.test]$ as --version
> GNU assembler (GNU Binutils) 2.41.50.20240105
> [fedora@linux 6.7.test]$ ld --version
> GNU ld (GNU Binutils) 2.41.50.20240105
>
> just switch the first and second arguments of kvcalloc() to silence
> the build warning, compile tested only.
>
> Fixes: bae12df966f0 ("btrfs: use kvcalloc for allocation in btrfs_ioctl_send()")
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Thanks, a fix has been already sent
https://lore.kernel.org/linux-btrfs/20231221084748.10094-1-dmantipov@yandex.ru/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-08 17:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-08 4:13 [PATCH] btrfs: send: Silence build warning about kvcalloc() Tiezhu Yang
2024-01-08 17:41 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®