2021-03-05 11:04:42

by Nanyong Sun

[permalink] [raw]
Subject: [PATCH 0/9] riscv: misc cleanup

Fix some compilation warnings,improve code style

Nanyong Sun (9):
riscv: traps: Fix no prototype warnings
riscv: irq: Fix no prototype warning
riscv: sbi: Fix comment of __sbi_set_timer_v01
riscv: ptrace: Fix no prototype warnings
riscv: time: Fix no prototype for time_init
riscv: syscall_table: Reduce W=1 compilation warnings noise
riscv: process: Fix no prototype for show_regs
riscv: ftrace: Use ftrace_get_regs helper
riscv: process: Fix no prototype for arch_dup_task_struct

arch/riscv/include/asm/asm-prototypes.h | 16 ++++++++++++++++
arch/riscv/include/asm/irq.h | 2 ++
arch/riscv/include/asm/processor.h | 1 +
arch/riscv/include/asm/ptrace.h | 5 +++++
arch/riscv/include/asm/timex.h | 2 ++
arch/riscv/kernel/Makefile | 1 +
arch/riscv/kernel/probes/ftrace.c | 16 +++++++++-------
arch/riscv/kernel/process.c | 1 +
arch/riscv/kernel/sbi.c | 2 +-
arch/riscv/kernel/time.c | 1 +
arch/riscv/kernel/traps.c | 1 +
11 files changed, 40 insertions(+), 8 deletions(-)

--
2.25.1


2021-03-05 11:04:42

by Nanyong Sun

[permalink] [raw]
Subject: [PATCH 6/9] riscv: syscall_table: Reduce W=1 compilation warnings noise

Building riscv syscall table with W=1 throws the warning as
following pattern:
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
./include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro ‘__SYSCALL’
29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
| ^~~~~~~~~
./include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro ‘__SC_COMP’
34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: note: (near initialization for ‘sys_call_table[0]’)
14 | #define __SYSCALL(nr, call) [nr] = (call),
| ^
./include/uapi/asm-generic/unistd.h:29:37: note: in expansion of macro ‘__SYSCALL’
29 | #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys)
| ^~~~~~~~~
./include/uapi/asm-generic/unistd.h:34:1: note: in expansion of macro ‘__SC_COMP’
34 | __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup)
| ^~~~~~~~~
arch/riscv/kernel/syscall_table.c:14:36: warning: initialized field overwritten [-Woverride-init]
...

Since we intentionally build the syscall tables this way,ignore the warning.

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Nanyong Sun <[email protected]>
---
arch/riscv/kernel/Makefile | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile
index 3dc0abde988a..647a47f5484a 100644
--- a/arch/riscv/kernel/Makefile
+++ b/arch/riscv/kernel/Makefile
@@ -8,6 +8,7 @@ CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_patch.o = $(CC_FLAGS_FTRACE)
CFLAGS_REMOVE_sbi.o = $(CC_FLAGS_FTRACE)
endif
+CFLAGS_syscall_table.o += $(call cc-option,-Wno-override-init,)

extra-y += head.o
extra-y += vmlinux.lds
--
2.25.1

2021-03-05 11:04:44

by Nanyong Sun

[permalink] [raw]
Subject: [PATCH 7/9] riscv: process: Fix no prototype for show_regs

Include header file to fix the following W=1 compilation warning:
arch/riscv/kernel/process.c:78:6: warning: no previous prototype for ‘show_regs’ [-Wmissing-prototypes]
78 | void show_regs(struct pt_regs *regs)
| ^~~~~~~~~

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Nanyong Sun <[email protected]>
---
arch/riscv/kernel/process.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index 6f728e731bed..f9cd57c9c67d 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -10,6 +10,7 @@
#include <linux/cpu.h>
#include <linux/kernel.h>
#include <linux/sched.h>
+#include <linux/sched/debug.h>
#include <linux/sched/task_stack.h>
#include <linux/tick.h>
#include <linux/ptrace.h>
--
2.25.1

2021-03-05 11:04:51

by Nanyong Sun

[permalink] [raw]
Subject: [PATCH 9/9] riscv: process: Fix no prototype for arch_dup_task_struct

Fix the following W=1 compilation warning:
arch/riscv/kernel/process.c:114:5: warning: no previous prototype for ‘arch_dup_task_struct’ [-Wmissing-prototypes]
114 | int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
| ^~~~~~~~~~~~~~~~~~~~

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Nanyong Sun <[email protected]>
---
arch/riscv/include/asm/processor.h | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h
index 3a240037bde2..021ed64ee608 100644
--- a/arch/riscv/include/asm/processor.h
+++ b/arch/riscv/include/asm/processor.h
@@ -71,6 +71,7 @@ int riscv_of_processor_hartid(struct device_node *node);
int riscv_of_parent_hartid(struct device_node *node);

extern void riscv_fill_hwcap(void);
+extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);

#endif /* __ASSEMBLY__ */

--
2.25.1

2021-03-05 11:04:53

by Nanyong Sun

[permalink] [raw]
Subject: [PATCH 3/9] riscv: sbi: Fix comment of __sbi_set_timer_v01

Fix the comment of __sbi_set_timer_v01, the function name in comment
is missing '__'

Signed-off-by: Nanyong Sun <[email protected]>
---
arch/riscv/kernel/sbi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
index f4a7db3d309e..d3bf756321a5 100644
--- a/arch/riscv/kernel/sbi.c
+++ b/arch/riscv/kernel/sbi.c
@@ -116,7 +116,7 @@ void sbi_clear_ipi(void)
EXPORT_SYMBOL(sbi_clear_ipi);

/**
- * sbi_set_timer_v01() - Program the timer for next timer event.
+ * __sbi_set_timer_v01() - Program the timer for next timer event.
* @stime_value: The value after which next timer event should fire.
*
* Return: None
--
2.25.1

2021-03-05 11:05:54

by Nanyong Sun

[permalink] [raw]
Subject: [PATCH 5/9] riscv: time: Fix no prototype for time_init

Fix the following W=1 compilation warning:
arch/riscv/kernel/time.c:16:13: warning: no previous prototype for ‘time_init’ [-Wmissing-prototypes]
16 | void __init time_init(void)
| ^~~~~~~~~

Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Nanyong Sun <[email protected]>
---
arch/riscv/include/asm/timex.h | 2 ++
arch/riscv/kernel/time.c | 1 +
2 files changed, 3 insertions(+)

diff --git a/arch/riscv/include/asm/timex.h b/arch/riscv/include/asm/timex.h
index 81de51e6aa32..507cae273bc6 100644
--- a/arch/riscv/include/asm/timex.h
+++ b/arch/riscv/include/asm/timex.h
@@ -88,4 +88,6 @@ static inline int read_current_timer(unsigned long *timer_val)
return 0;
}

+extern void time_init(void);
+
#endif /* _ASM_RISCV_TIMEX_H */
diff --git a/arch/riscv/kernel/time.c b/arch/riscv/kernel/time.c
index 8a5cf99c0776..1b432264f7ef 100644
--- a/arch/riscv/kernel/time.c
+++ b/arch/riscv/kernel/time.c
@@ -9,6 +9,7 @@
#include <linux/delay.h>
#include <asm/sbi.h>
#include <asm/processor.h>
+#include <asm/timex.h>

unsigned long riscv_timebase;
EXPORT_SYMBOL_GPL(riscv_timebase);
--
2.25.1

2021-03-10 05:07:16

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH 0/9] riscv: misc cleanup

On Fri, 05 Mar 2021 03:33:23 PST (-0800), [email protected] wrote:
> Fix some compilation warnings,improve code style
>
> Nanyong Sun (9):
> riscv: traps: Fix no prototype warnings
> riscv: irq: Fix no prototype warning
> riscv: sbi: Fix comment of __sbi_set_timer_v01
> riscv: ptrace: Fix no prototype warnings
> riscv: time: Fix no prototype for time_init
> riscv: syscall_table: Reduce W=1 compilation warnings noise
> riscv: process: Fix no prototype for show_regs
> riscv: ftrace: Use ftrace_get_regs helper
> riscv: process: Fix no prototype for arch_dup_task_struct
>
> arch/riscv/include/asm/asm-prototypes.h | 16 ++++++++++++++++
> arch/riscv/include/asm/irq.h | 2 ++
> arch/riscv/include/asm/processor.h | 1 +
> arch/riscv/include/asm/ptrace.h | 5 +++++
> arch/riscv/include/asm/timex.h | 2 ++
> arch/riscv/kernel/Makefile | 1 +
> arch/riscv/kernel/probes/ftrace.c | 16 +++++++++-------
> arch/riscv/kernel/process.c | 1 +
> arch/riscv/kernel/sbi.c | 2 +-
> arch/riscv/kernel/time.c | 1 +
> arch/riscv/kernel/traps.c | 1 +
> 11 files changed, 40 insertions(+), 8 deletions(-)

Thanks. I fixed the checkpatch warning, these are all on fixes.