[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220618101134.3073210-1-fanjun.kong@linux.dev>
Date:   Sat, 18 Jun 2022 18:11:34 +0800
From:   Fanjun Kong <fanjun.kong@...ux.dev>
To:     Dave Hansen <dave.hansen@...ux.intel.com>,
        Andy Lutomirski <luto@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>
Cc:     Muchun Song <songmuchun@...edance.com>,
        Fanjun Kong <fanjun.kong@...ux.dev>,
        linux-kernel@...r.kernel.org
Subject: [PATCH] x86/mm: declare static variable inside a function instead of global
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@...ux.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
Powered by blists - more mailing lists