b/arch/x86/mm/pti.c - make local symbols static
PATCH 1/1 b/arch/x86/mm/pti.c - make local symbols static
With 'make C=2 W=1', sparse and gcc both complain:
CHECK arch/x86/mm/pti.carch/x86/mm/pti.c:84:3: warning: symbol 'pti_mode' was not declared. Should it be static? arch/x86/mm/pti.c:605:6: warning: symbol 'pti_set_kernel_image_nonglobal' was not declared. Should it be static?
CC arch/x86/mm/pti.oarch/x86/mm/pti.c:605:6: warning: no previous prototype for 'pti_set_kernel_image_nonglobal' [-Wmissing-prototypes]
605 | void pti_set_kernel_image_nonglobal(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And indeed, the function at line 605 is only used locally. 'pti_mode' is more subtle - there is another pti_mode in drivers/hwtracing/intel_th/pti.c, but it's an array declared static, not an enum
Make both variables static.
---
arch/x86/mm/pti.c +2 -2
@@ -77,7 +77,7 @@ static void __init pti_print_if_secure(const char *reason)pr_info ("%s\n" , reason); } -enum pti_mode { +static enum pti_mode { PTI_AUTO = 0, PTI_FORCE_OFF, PTI_FORCE_ON
@@ -602,7 +602,7 @@ static void pti_clone_kernel_text(void)set_memory_global (start, (end_global - start) >>PAGE_SHIFT ); } -void pti_set_kernel_image_nonglobal (void ) +static void pti_set_kernel_image_nonglobal (void ) {/* * The identity map is created with PMDs, regardless of the
Quoted 1 line
Make both variables static.
"pti_set_kernel_image_nonglobal(void)" is an awfully funny looking variable. ;)
arch/x86/mm/pti.c static void __init pti_print_if_secure(const char *reason) · line 80
Quoted 13 lines
Signed-off-by Valdis Kletnieks <[email protected]>---
arch/x86/mm/pti.c +1
-1@@ -77,7 +77,7 @@ static void __init pti_print_if_secure(const char *reason)pr_info ("%s\n" , reason); } -enum pti_mode { +static enum pti_mode {
I'm struggling to figure out why we would want to do this. If there's a really good reason, I think we probably need to do it en masse:
$ grep -r '^enum.{' arch/x86/ | wc -l
48arch/x86/mm/pti.c static void pti_clone_kernel_text(void) · line 605
Quoted 9 lines
arch/x86/mm/pti.c +1
-1PTI_AUTO =0 ,PTI_FORCE_OFF ,PTI_FORCE_ON @@ -602,7 +602,7 @@ static void pti_clone_kernel_text(void)set_memory_global (start, (end_global - start) >>PAGE_SHIFT ); } -void pti_set_kernel_image_nonglobal (void ) +static void pti_set_kernel_image_nonglobal (void )
Yes, this function should be static.
Quoted 16 lines · Dave Hansen
Quoted 1 line
Make both variables static.
"
pti_set_kernel_image_nonglobal(void)" is an awfully funny looking variable. ;)Quoted 11 lines
Signed-off-by Valdis Kletnieks <[email protected]>---
arch/x86/mm/pti.c +0
-0@@ -77,7 +77,7 @@ static void __init pti_print_if_secure(const char *reason)pr_info ("%s\n" , reason); }
Quoted 5 lines
arch/x86/mm/pti.c static void __init pti_print_if_secure(const char *reason) · line 80
Quoted 2 lines
arch/x86/mm/pti.c +1
-1-enum pti_mode { +static enum pti_mode {I'm struggling to figure out why we would want to do this. If there's a really good reason, I think we probably need to do it en masse:
Because its:
enum pti_mode {
....
} pti_mode;
So that's both enum and variable declaration.
Quoted 2 lines
$ grep -r '^enum.{' arch/x86/ | wc -l
48In the other cases it's a enum declaration without declaring a variable at the same time. Making them static would be obviously bogus.
Thanks,
tglx
Thomas Gleixner
AppliedValdis,
On Tue, 12 Mar 2019, Valdis Klētnieks wrote:
I've applied the lot, but I had to fixup the subject lines.
# git log path/to/file
gives you a decent hint on what the usual prefix and format is.
'b/arch/x86/mm/pti.c -'
is obviously not.
Thanks,
tglx
tip-bot for Valdis Kletnieks
merge bot[tip:x86/urgent] x86/mm/pti: Make local symbols static
In reply to Valdis Kl=?utf-8?Q?=c4=93?=tnieksx86/mm/pti: Make local symbols static
Commit-ID: 4fe64a62e04cfb2dc1daab0d8f05d212aa014161 Gitweb: https://git.kernel.org/tip/4fe64a62e04cfb2dc1daab0d8f05d212aa014161 Author: Valdis Kletnieks <[email protected]> AuthorDate: Tue, 12 Mar 2019 03:47:53 -0400 Committer: Thomas Gleixner <[email protected]> CommitDate: Fri, 22 Mar 2019 13:31:28 +0100
x86/mm/pti: Make local symbols static
With 'make C=2 W=1', sparse and gcc both complain:
CHECK arch/x86/mm/pti.carch/x86/mm/pti.c:84:3: warning: symbol 'pti_mode' was not declared. Should it be static? arch/x86/mm/pti.c:605:6: warning: symbol 'pti_set_kernel_image_nonglobal' was not declared. Should it be static?
CC arch/x86/mm/pti.oarch/x86/mm/pti.c:605:6: warning: no previous prototype for 'pti_set_kernel_image_nonglobal' [-Wmissing-prototypes]
605 | void pti_set_kernel_image_nonglobal(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pti_set_kernel_image_nonglobal() is only used locally. 'pti_mode' exists in drivers/hwtracing/intel_th/pti.c as well, but it's a completely unrelated local (static) symbol.
Make both static.
--- arch/x86/mm/pti.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/pti.c +2 -2
@@ -77,7 +77,7 @@ static void __init pti_print_if_secure(const char *reason)pr_info ("%s\n" , reason); } -enum pti_mode { +static enum pti_mode { PTI_AUTO = 0, PTI_FORCE_OFF, PTI_FORCE_ON
@@ -602,7 +602,7 @@ static void pti_clone_kernel_text(void)set_memory_global (start, (end_global - start) >>PAGE_SHIFT ); } -void pti_set_kernel_image_nonglobal (void ) +static void pti_set_kernel_image_nonglobal (void ) {/* * The identity map is created with PMDs, regardless of the