RE: [PATCH v2] fs/proc: Optimize arrays defined by struct ctl_path

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

 



From: Meng Tang <tangmeng@xxxxxxxxxxxxx>
> Sent: 24 February 2022 10:53
> 
> Previously, arrays defined by struct ctl_path is terminated
> with an empty one. For example, when we actually only register
> one ctl_path, we've gone from 8 bytes to 16 bytes.
> 
...
> diff --git a/arch/csky/abiv1/alignment.c b/arch/csky/abiv1/alignment.c
> index 2df115d0e210..b9290a252d84 100644
> --- a/arch/csky/abiv1/alignment.c
> +++ b/arch/csky/abiv1/alignment.c
> @@ -340,14 +340,14 @@ static struct ctl_table sysctl_table[2] = {
>  	{}
>  };
> 
> -static struct ctl_path sysctl_path[2] = {
> -	{.procname = "csky"},
> -	{}
> +static struct ctl_path sysctl_path[1] = {
> +	{.procname = "csky"}
>  };
> +#define SYSCTL_PATH_NUM ARRAY_SIZE(sysctl_path)
> 
>  static int __init csky_alignment_init(void)
>  {
> -	 (sysctl_path, sysctl_table);
> +	register_sysctl_paths(sysctl_path, SYSCTL_PATH_NUM, sysctl_table);
>  	return 0;
>  }

That is horribly error prone.
What might work is to add the ctl_path_num parameter but leave in the
check for NULL.
Then add:

#define register_sysctl_paths(p, t) register_sysctl_paths(p, ARRAY_SIZE(t), t)

in the header file after the prototype.
Put the function name in () in the definition to stop the macro expansion.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux