lkml.org 
[lkml]   [2022]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] x86/mm: declare static variable inside a function instead of global
Date
Global variables are global capacity variables, unless they are
shadowed, they are available to the entire program.
To reduce the scope of a variable as much as possible is always good
practice.

Signed-off-by: Fanjun Kong <fanjun.kong@linux.dev>
---
arch/x86/mm/init_64.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 39c5246964a9..582eab896480 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1515,9 +1515,10 @@ static unsigned long probe_memory_block_size(void)
return bz;
}

-static unsigned long memory_block_size_probed;
unsigned long memory_block_size_bytes(void)
{
+ static unsigned long memory_block_size_probed;
+
if (!memory_block_size_probed)
memory_block_size_probed = probe_memory_block_size();

--
2.36.0
\
 
 \ /
  Last update: 2022-06-18 12:12    [W:0.036 / U:0.524 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site