2023-10-01 17:25:18

by Chuck Lever

[permalink] [raw]
Subject: [PATCH RFC 1/2] NFSD: Rewrite synopsis of nfsd_percpu_counters_init()

From: Chuck Lever <[email protected]>

In function ‘export_stats_init’,
inlined from ‘svc_export_alloc’ at /home/cel/src/linux/server-development/fs/nfsd/export.c:866:6:
/home/cel/src/linux/server-development/fs/nfsd/export.c:337:16: warning: ‘nfsd_percpu_counters_init’ accessing 40 bytes in a region of size 0 [-Wstringop-overflow=]
337 | return nfsd_percpu_counters_init(&stats->counter, EXP_STATS_COUNTERS_NUM);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/cel/src/linux/server-development/fs/nfsd/export.c:337:16: note: referencing argument 1 of type ‘struct percpu_counter[0]’
/home/cel/src/linux/server-development/fs/nfsd/stats.h: In function ‘svc_export_alloc’:
/home/cel/src/linux/server-development/fs/nfsd/stats.h:40:5: note: in a call to function ‘nfsd_percpu_counters_init’
40 | int nfsd_percpu_counters_init(struct percpu_counter counters[], int num);
| ^~~~~~~~~~~~~~~~~~~~~~~~~

Cc: Amir Goldstein <[email protected]>
Signed-off-by: Chuck Lever <[email protected]>
---
fs/nfsd/stats.c | 2 +-
fs/nfsd/stats.h | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c
index 63797635e1c3..12c299a05433 100644
--- a/fs/nfsd/stats.c
+++ b/fs/nfsd/stats.c
@@ -76,7 +76,7 @@ static int nfsd_show(struct seq_file *seq, void *v)

DEFINE_PROC_SHOW_ATTRIBUTE(nfsd);

-int nfsd_percpu_counters_init(struct percpu_counter counters[], int num)
+int nfsd_percpu_counters_init(struct percpu_counter *counters, int num)
{
int i, err = 0;

diff --git a/fs/nfsd/stats.h b/fs/nfsd/stats.h
index cf5524e7ca06..a3e9e2f47ec4 100644
--- a/fs/nfsd/stats.h
+++ b/fs/nfsd/stats.h
@@ -37,9 +37,9 @@ extern struct nfsd_stats nfsdstats;

extern struct svc_stat nfsd_svcstats;

-int nfsd_percpu_counters_init(struct percpu_counter counters[], int num);
-void nfsd_percpu_counters_reset(struct percpu_counter counters[], int num);
-void nfsd_percpu_counters_destroy(struct percpu_counter counters[], int num);
+int nfsd_percpu_counters_init(struct percpu_counter *counters, int num);
+void nfsd_percpu_counters_reset(struct percpu_counter *counters, int num);
+void nfsd_percpu_counters_destroy(struct percpu_counter *counters, int num);
int nfsd_stat_init(void);
void nfsd_stat_shutdown(void);




2023-10-02 13:50:12

by Jeff Layton

[permalink] [raw]
Subject: Re: [PATCH RFC 1/2] NFSD: Rewrite synopsis of nfsd_percpu_counters_init()

On Sun, 2023-10-01 at 13:25 -0400, Chuck Lever wrote:
> From: Chuck Lever <[email protected]>
>
> In function ‘export_stats_init’,
> inlined from ‘svc_export_alloc’ at /home/cel/src/linux/server-development/fs/nfsd/export.c:866:6:
> /home/cel/src/linux/server-development/fs/nfsd/export.c:337:16: warning: ‘nfsd_percpu_counters_init’ accessing 40 bytes in a region of size 0 [-Wstringop-overflow=]
> 337 | return nfsd_percpu_counters_init(&stats->counter, EXP_STATS_COUNTERS_NUM);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/cel/src/linux/server-development/fs/nfsd/export.c:337:16: note: referencing argument 1 of type ‘struct percpu_counter[0]’
> /home/cel/src/linux/server-development/fs/nfsd/stats.h: In function ‘svc_export_alloc’:
> /home/cel/src/linux/server-development/fs/nfsd/stats.h:40:5: note: in a call to function ‘nfsd_percpu_counters_init’
> 40 | int nfsd_percpu_counters_init(struct percpu_counter counters[], int num);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~
>
> Cc: Amir Goldstein <[email protected]>
> Signed-off-by: Chuck Lever <[email protected]>
> ---
> fs/nfsd/stats.c | 2 +-
> fs/nfsd/stats.h | 6 +++---
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c
> index 63797635e1c3..12c299a05433 100644
> --- a/fs/nfsd/stats.c
> +++ b/fs/nfsd/stats.c
> @@ -76,7 +76,7 @@ static int nfsd_show(struct seq_file *seq, void *v)
>
> DEFINE_PROC_SHOW_ATTRIBUTE(nfsd);
>
> -int nfsd_percpu_counters_init(struct percpu_counter counters[], int num)
> +int nfsd_percpu_counters_init(struct percpu_counter *counters, int num)
> {
> int i, err = 0;
>
> diff --git a/fs/nfsd/stats.h b/fs/nfsd/stats.h
> index cf5524e7ca06..a3e9e2f47ec4 100644
> --- a/fs/nfsd/stats.h
> +++ b/fs/nfsd/stats.h
> @@ -37,9 +37,9 @@ extern struct nfsd_stats nfsdstats;
>
> extern struct svc_stat nfsd_svcstats;
>
> -int nfsd_percpu_counters_init(struct percpu_counter counters[], int num);
> -void nfsd_percpu_counters_reset(struct percpu_counter counters[], int num);
> -void nfsd_percpu_counters_destroy(struct percpu_counter counters[], int num);
> +int nfsd_percpu_counters_init(struct percpu_counter *counters, int num);
> +void nfsd_percpu_counters_reset(struct percpu_counter *counters, int num);
> +void nfsd_percpu_counters_destroy(struct percpu_counter *counters, int num);
> int nfsd_stat_init(void);
> void nfsd_stat_shutdown(void);
>
>
>

Reviewed-by: Jeff Layton <[email protected]>