lkml.org 
[lkml]   [2022]   [Jun]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] x86/mm: declare static variable inside a function instead of global
From
On 6/18/22 03:11, Fanjun Kong wrote:
> Global variables are global capacity variables, unless they are
> shadowed, they are available to the entire program.

This is true in general, but:

> -static unsigned long memory_block_size_probed;

^^^^^^

So this isn't actually the case.

> 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();
>

I'm sort of okay with the patch, but it's worth noting that, in C++,
initialized function-scope static variables have quite surprising
semantics, so this type of change isn't a pure win in my book. (Yes,
the kernel is C, not C++. But C++ programmers may be nervous anyway.)

\
 
 \ /
  Last update: 2022-06-29 01:47    [W:0.543 / U:0.400 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site