lkml.org 
[lkml]   [2022]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2] fs/proc: Optimize arrays defined by struct ctl_path
Date
From: Meng Tang <tangmeng@uniontech.com>
> 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)

\
 
 \ /
  Last update: 2022-02-24 12:07    [W:0.042 / U:0.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site