Message ID | 20191018080841.26712-6-paul.walmsley@sifive.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | riscv: resolve most warnings from sparse | expand |
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
Paul Walmsley <paul.walmsley@sifive.com> 於 2019年10月19日 週六 下午3:58寫道: > > Several functions and arrays which are only used in the files in which > they are declared are missing "static" qualifiers. Warnings for these > symbols are reported by sparse: > > arch/riscv/kernel/stacktrace.c:22:14: warning: symbol 'walk_stackframe' was not declared. Should it be static? > arch/riscv/kernel/vdso.c:28:18: warning: symbol 'vdso_data' was not declared. Should it be static? > arch/riscv/mm/init.c:42:6: warning: symbol 'setup_zero_page' was not declared. Should it be static? > arch/riscv/mm/init.c:152:7: warning: symbol 'fixmap_pte' was not declared. Should it be static? > arch/riscv/mm/init.c:211:7: warning: symbol 'trampoline_pmd' was not declared. Should it be static? > arch/riscv/mm/init.c:212:7: warning: symbol 'fixmap_pmd' was not declared. Should it be static? > arch/riscv/mm/init.c:219:7: warning: symbol 'early_pmd' was not declared. Should it be static? > arch/riscv/mm/sifive_l2_cache.c:145:12: warning: symbol 'sifive_l2_init' was not declared. Should it be static? > > Resolve these warnings by marking them as static. > > Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com> > --- > arch/riscv/kernel/stacktrace.c | 6 ++++-- > arch/riscv/kernel/vdso.c | 2 +- > arch/riscv/mm/init.c | 12 +++++++----- > arch/riscv/mm/sifive_l2_cache.c | 2 +- > 4 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c > index 0940681d2f68..fd908baed51c 100644 > --- a/arch/riscv/kernel/stacktrace.c > +++ b/arch/riscv/kernel/stacktrace.c > @@ -19,8 +19,10 @@ struct stackframe { > unsigned long ra; > }; > > -void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, > - bool (*fn)(unsigned long, void *), void *arg) > +static void notrace walk_stackframe(struct task_struct *task, > + struct pt_regs *regs, > + bool (*fn)(unsigned long, void *), > + void *arg) I think walk_stackframe() could not be static because it will be used in perf_callchain.c.
On Wed, 23 Oct 2019, Greentime Hu wrote: > Paul Walmsley <paul.walmsley@sifive.com> 於 2019年10月19日 週六 下午3:58寫道: > > > > Several functions and arrays which are only used in the files in which > > they are declared are missing "static" qualifiers. Warnings for these > > symbols are reported by sparse: > > > > arch/riscv/kernel/stacktrace.c:22:14: warning: symbol 'walk_stackframe' was not declared. Should it be static? [ ... ] > I think walk_stackframe() could not be static because it will be used > in perf_callchain.c. Thanks Greentime - will update the patch. - Paul
diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c index 0940681d2f68..fd908baed51c 100644 --- a/arch/riscv/kernel/stacktrace.c +++ b/arch/riscv/kernel/stacktrace.c @@ -19,8 +19,10 @@ struct stackframe { unsigned long ra; }; -void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, - bool (*fn)(unsigned long, void *), void *arg) +static void notrace walk_stackframe(struct task_struct *task, + struct pt_regs *regs, + bool (*fn)(unsigned long, void *), + void *arg) { unsigned long fp, sp, pc; diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c index c9c21e0d5641..e24fccab8185 100644 --- a/arch/riscv/kernel/vdso.c +++ b/arch/riscv/kernel/vdso.c @@ -25,7 +25,7 @@ static union { struct vdso_data data; u8 page[PAGE_SIZE]; } vdso_data_store __page_aligned_data; -struct vdso_data *vdso_data = &vdso_data_store.data; +static struct vdso_data *vdso_data = &vdso_data_store.data; static int __init vdso_init(void) { diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index fe68e94ea946..79cfb35f1e0e 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -40,7 +40,7 @@ static void __init zone_sizes_init(void) free_area_init_nodes(max_zone_pfns); } -void setup_zero_page(void) +static void setup_zero_page(void) { memset((void *)empty_zero_page, 0, PAGE_SIZE); } @@ -150,7 +150,7 @@ EXPORT_SYMBOL(pfn_base); void *dtb_early_va; pgd_t swapper_pg_dir[PTRS_PER_PGD] __page_aligned_bss; pgd_t trampoline_pg_dir[PTRS_PER_PGD] __page_aligned_bss; -pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss; +static pte_t fixmap_pte[PTRS_PER_PTE] __page_aligned_bss; static bool mmu_enabled; #define MAX_EARLY_MAPPING_SIZE SZ_128M @@ -209,15 +209,17 @@ static void __init create_pte_mapping(pte_t *ptep, #ifndef __PAGETABLE_PMD_FOLDED -pmd_t trampoline_pmd[PTRS_PER_PMD] __page_aligned_bss; -pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss; +static pmd_t trampoline_pmd[PTRS_PER_PMD] __page_aligned_bss; +static pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss; #if MAX_EARLY_MAPPING_SIZE < PGDIR_SIZE #define NUM_EARLY_PMDS 1UL #else #define NUM_EARLY_PMDS (1UL + MAX_EARLY_MAPPING_SIZE / PGDIR_SIZE) #endif -pmd_t early_pmd[PTRS_PER_PMD * NUM_EARLY_PMDS] __initdata __aligned(PAGE_SIZE); + +#define NUM_EARLY_PMDS_PTRS (PTRS_PER_PMD * NUM_EARLY_PMDS) +static pmd_t early_pmd[NUM_EARLY_PMDS_PTRS] __initdata __aligned(PAGE_SIZE); static pmd_t *__init get_pmd_virt(phys_addr_t pa) { diff --git a/arch/riscv/mm/sifive_l2_cache.c b/arch/riscv/mm/sifive_l2_cache.c index 2e637ad71c05..a9ffff3277c7 100644 --- a/arch/riscv/mm/sifive_l2_cache.c +++ b/arch/riscv/mm/sifive_l2_cache.c @@ -142,7 +142,7 @@ static irqreturn_t l2_int_handler(int irq, void *device) return IRQ_HANDLED; } -int __init sifive_l2_init(void) +static int __init sifive_l2_init(void) { struct device_node *np; struct resource res;
Several functions and arrays which are only used in the files in which they are declared are missing "static" qualifiers. Warnings for these symbols are reported by sparse: arch/riscv/kernel/stacktrace.c:22:14: warning: symbol 'walk_stackframe' was not declared. Should it be static? arch/riscv/kernel/vdso.c:28:18: warning: symbol 'vdso_data' was not declared. Should it be static? arch/riscv/mm/init.c:42:6: warning: symbol 'setup_zero_page' was not declared. Should it be static? arch/riscv/mm/init.c:152:7: warning: symbol 'fixmap_pte' was not declared. Should it be static? arch/riscv/mm/init.c:211:7: warning: symbol 'trampoline_pmd' was not declared. Should it be static? arch/riscv/mm/init.c:212:7: warning: symbol 'fixmap_pmd' was not declared. Should it be static? arch/riscv/mm/init.c:219:7: warning: symbol 'early_pmd' was not declared. Should it be static? arch/riscv/mm/sifive_l2_cache.c:145:12: warning: symbol 'sifive_l2_init' was not declared. Should it be static? Resolve these warnings by marking them as static. Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com> --- arch/riscv/kernel/stacktrace.c | 6 ++++-- arch/riscv/kernel/vdso.c | 2 +- arch/riscv/mm/init.c | 12 +++++++----- arch/riscv/mm/sifive_l2_cache.c | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-)