Re: [PATCH 1/2] virtiofs: Improve three size determinations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 29, 2023 at 09:36:36AM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> 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@xxxxxxxxxxxxxxxxxxxxx>
> ---
>  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
> 
> 





[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux