loongarch.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Fix build warnings in VDSO
@ 2022-08-20 15:35 Huacai Chen
  2022-08-24 10:09 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Huacai Chen @ 2022-08-20 15:35 UTC (permalink / raw)
  To: Huacai Chen
  Cc: loongarch, Xuefeng Li, Guo Ren, Xuerui Wang, Jiaxun Yang,
	linux-kernel, Huacai Chen, kernel test robot

Fix build warnings in VDSO as below:

arch/loongarch/vdso/vgettimeofday.c:9:5: warning: no previous prototype for '__vdso_clock_gettime' [-Wmissing-prototypes]
    9 | int __vdso_clock_gettime(clockid_t clock,
      |     ^~~~~~~~~~~~~~~~~~~~
arch/loongarch/vdso/vgettimeofday.c:15:5: warning: no previous prototype for '__vdso_gettimeofday' [-Wmissing-prototypes]
   15 | int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
      |     ^~~~~~~~~~~~~~~~~~~
arch/loongarch/vdso/vgettimeofday.c:21:5: warning: no previous prototype for '__vdso_clock_getres' [-Wmissing-prototypes]
   21 | int __vdso_clock_getres(clockid_t clock_id,
      |     ^~~~~~~~~~~~~~~~~~~
arch/loongarch/vdso/vgetcpu.c:27:5: warning: no previous prototype for '__vdso_getcpu' [-Wmissing-prototypes]
   27 | int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused)

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 arch/loongarch/vdso/vgetcpu.c       |  2 ++
 arch/loongarch/vdso/vgettimeofday.c | 15 +++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/arch/loongarch/vdso/vgetcpu.c b/arch/loongarch/vdso/vgetcpu.c
index 43a0078e4418..e02e775f5360 100644
--- a/arch/loongarch/vdso/vgetcpu.c
+++ b/arch/loongarch/vdso/vgetcpu.c
@@ -24,6 +24,8 @@ static __always_inline const struct vdso_pcpu_data *get_pcpu_data(void)
 	return (struct vdso_pcpu_data *)(get_vdso_base() - VDSO_DATA_SIZE);
 }
 
+extern
+int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused);
 int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused)
 {
 	int cpu_id;
diff --git a/arch/loongarch/vdso/vgettimeofday.c b/arch/loongarch/vdso/vgettimeofday.c
index b1f4548dae92..8f22863bd7ea 100644
--- a/arch/loongarch/vdso/vgettimeofday.c
+++ b/arch/loongarch/vdso/vgettimeofday.c
@@ -6,20 +6,23 @@
  */
 #include <linux/types.h>
 
-int __vdso_clock_gettime(clockid_t clock,
-			 struct __kernel_timespec *ts)
+extern
+int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts);
+int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
 {
 	return __cvdso_clock_gettime(clock, ts);
 }
 
-int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
-			struct timezone *tz)
+extern
+int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz);
+int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
 {
 	return __cvdso_gettimeofday(tv, tz);
 }
 
-int __vdso_clock_getres(clockid_t clock_id,
-			struct __kernel_timespec *res)
+extern
+int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res);
+int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res)
 {
 	return __cvdso_clock_getres(clock_id, res);
 }
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] LoongArch: Fix build warnings in VDSO
  2022-08-20 15:35 [PATCH] LoongArch: Fix build warnings in VDSO Huacai Chen
@ 2022-08-24 10:09 ` Arnd Bergmann
  2022-08-24 12:49   ` Huacai Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2022-08-24 10:09 UTC (permalink / raw)
  To: Huacai Chen
  Cc: Huacai Chen, loongarch, Xuefeng Li, Guo Ren, Xuerui Wang,
	Jiaxun Yang, linux-kernel, kernel test robot

On Sat, Aug 20, 2022 at 5:35 PM Huacai Chen <chenhuacai@loongson.cn> wrote:
>
> diff --git a/arch/loongarch/vdso/vgetcpu.c b/arch/loongarch/vdso/vgetcpu.c
> index 43a0078e4418..e02e775f5360 100644
> --- a/arch/loongarch/vdso/vgetcpu.c
> +++ b/arch/loongarch/vdso/vgetcpu.c
> @@ -24,6 +24,8 @@ static __always_inline const struct vdso_pcpu_data *get_pcpu_data(void)
>         return (struct vdso_pcpu_data *)(get_vdso_base() - VDSO_DATA_SIZE);
>  }
>
> +extern
> +int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused);
>  int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused)
>  {

I don't think that adding the declaration before the function is a
good workaround here,
that is likely to just trigger another warning about declarations in .c files.

I would add the declarations into a header file instead. If the
prototypes are the same
across architectures, this can be a global header that also avoids the
warnings elsewhere,
otherwise just keep it local to this directory.

      Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] LoongArch: Fix build warnings in VDSO
  2022-08-24 10:09 ` Arnd Bergmann
@ 2022-08-24 12:49   ` Huacai Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Huacai Chen @ 2022-08-24 12:49 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Huacai Chen, loongarch, Xuefeng Li, Guo Ren, Xuerui Wang,
	Jiaxun Yang, LKML, kernel test robot

Hi, Arnd,

On Wed, Aug 24, 2022 at 6:10 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> On Sat, Aug 20, 2022 at 5:35 PM Huacai Chen <chenhuacai@loongson.cn> wrote:
> >
> > diff --git a/arch/loongarch/vdso/vgetcpu.c b/arch/loongarch/vdso/vgetcpu.c
> > index 43a0078e4418..e02e775f5360 100644
> > --- a/arch/loongarch/vdso/vgetcpu.c
> > +++ b/arch/loongarch/vdso/vgetcpu.c
> > @@ -24,6 +24,8 @@ static __always_inline const struct vdso_pcpu_data *get_pcpu_data(void)
> >         return (struct vdso_pcpu_data *)(get_vdso_base() - VDSO_DATA_SIZE);
> >  }
> >
> > +extern
> > +int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused);
> >  int __vdso_getcpu(unsigned int *cpu, unsigned int *node, struct getcpu_cache *unused)
> >  {
>
> I don't think that adding the declaration before the function is a
> good workaround here,
> that is likely to just trigger another warning about declarations in .c files.
Yes, this is not a good solution, I just use the same method as RISC-V. :)
But "another warning" is a checkpatch warning, not a build warning, so
lkp@intel.com will not send bug reports again and again. :)

>
> I would add the declarations into a header file instead. If the
> prototypes are the same
> across architectures, this can be a global header that also avoids the
> warnings elsewhere,
> otherwise just keep it local to this directory.
gettimeofday, clock_gettime and clock_getres can be declared across
architectures, but getcpu seems not suitable because not all
architectures have it.

Huacai

>
>       Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-24 12:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-20 15:35 [PATCH] LoongArch: Fix build warnings in VDSO Huacai Chen
2022-08-24 10:09 ` Arnd Bergmann
2022-08-24 12:49   ` Huacai Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).