[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZZR1FxR4cUzuDzLK@redhat.com>
Date: Tue, 2 Jan 2024 15:41:59 -0500
From: Vivek Goyal <vgoyal@...hat.com>
To: Markus Elfring <Markus.Elfring@....de>
Cc: virtualization@...ts.linux.dev, linux-fsdevel@...r.kernel.org,
kernel-janitors@...r.kernel.org, Miklos Szeredi <miklos@...redi.hu>,
Stefan Hajnoczi <stefanha@...hat.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/2] virtiofs: Improve three size determinations
On Fri, Dec 29, 2023 at 09:36:36AM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Fri, 29 Dec 2023 08:42:04 +0100
>
> Replace the specification of data structures by pointer dereferences
> as the parameter for the operator “sizeof” to make the corresponding size
> determination a bit safer according to the Linux coding style convention.
I had a look at coding-style.rst and it does say that dereferencing the
pointer is preferred form. Primary argument seems to be that somebody
might change the pointer variable type but not the corresponding type
passed to sizeof().
There is some value to the argument. I don't feel strongly about it.
Miklos, if you like this change, feel free to apply.
Thanks
Vivek
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
> fs/fuse/virtio_fs.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
> index 5f1be1da92ce..2f8ba9254c1e 100644
> --- a/fs/fuse/virtio_fs.c
> +++ b/fs/fuse/virtio_fs.c
> @@ -1435,11 +1435,11 @@ static int virtio_fs_get_tree(struct fs_context *fsc)
> goto out_err;
>
> err = -ENOMEM;
> - fc = kzalloc(sizeof(struct fuse_conn), GFP_KERNEL);
> + fc = kzalloc(sizeof(*fc), GFP_KERNEL);
> if (!fc)
> goto out_err;
>
> - fm = kzalloc(sizeof(struct fuse_mount), GFP_KERNEL);
> + fm = kzalloc(sizeof(*fm), GFP_KERNEL);
> if (!fm)
> goto out_err;
>
> @@ -1495,7 +1495,7 @@ static int virtio_fs_init_fs_context(struct fs_context *fsc)
> if (fsc->purpose == FS_CONTEXT_FOR_SUBMOUNT)
> return fuse_init_fs_context_submount(fsc);
>
> - ctx = kzalloc(sizeof(struct fuse_fs_context), GFP_KERNEL);
> + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> if (!ctx)
> return -ENOMEM;
> fsc->fs_private = ctx;
> --
> 2.43.0
>
>
Powered by blists - more mailing lists