lkml.org 
[lkml]   [2021]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [External] [PATCH] memcontrol: use flexible-array member
On Tue, May 18, 2021 at 1:20 PM wenhuizhang <wenhui@gwmail.gwu.edu> wrote:
>
>
> Change depracated zero-length-and-one-element-arrays into flexible
> array member.
> Zero-length and one-element arrays detected by Lukas's CodeChecker.
> Zero/one element arrays causes undefined behaviours if sizeof() used.
>
> https://www.kernel.org/doc/html/latest/processd/deprecated.html
>
>
> Signed-off-by: wenhuizhang<wenhui@gwmail.gwu.edu>
> ---
> include/linux/memcontrol.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 0ce97eff79e2..f879efb1bc6e 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -190,7 +190,7 @@ enum memcg_kmem_state {
>
> #if defined(CONFIG_SMP)
> struct memcg_padding {
> - char x[0];
> + char x[];

Have you tested this?

The compiler will complain about this. The output will be something like below.

error: flexible array member in otherwise empty struct

Thanks.

> } ____cacheline_internodealigned_in_smp;
> #define MEMCG_PADDING(name) struct memcg_padding name;
> #else
> @@ -349,7 +349,7 @@ struct mem_cgroup {
> struct deferred_split deferred_split_queue;
> #endif
>
> - struct mem_cgroup_per_node *nodeinfo[0];
> + struct mem_cgroup_per_node *nodeinfo[];
> /* WARNING: nodeinfo must be the last member here */
> };
>
> --
> 2.17.1
>

\
 
 \ /
  Last update: 2021-05-18 08:36    [W:0.052 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site