The Sparse tool reports as follows:
drivers/base/node.c:239:1: warning:
symbol 'dev_attr_line_size' was not declared. Should it be static?
drivers/base/node.c:240:1: warning:
symbol 'dev_attr_indexing' was not declared. Should it be static?
These symbols (and several others) are defined by DEVICE_ATTR_RO(name) in
CACHE_ATTR(name, fmt), and all of them are not used outside of node.c. So let's
mark DEVICE_ATTR_RO(name) static to solve these complains from Sparse.
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Ruiqi Gong <[email protected]>
---
drivers/base/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/node.c b/drivers/base/node.c
index f449dbb2c746..27f251c2742a 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -233,7 +233,7 @@ static ssize_t name##_show(struct device *dev, \
return sysfs_emit(buf, fmt "\n", \
to_cache_info(dev)->cache_attrs.name); \
} \
-DEVICE_ATTR_RO(name);
+static DEVICE_ATTR_RO(name);
CACHE_ATTR(size, "%llu")
CACHE_ATTR(line_size, "%u")
On Thu, May 13, 2021 at 07:07:16PM +0800, Ruiqi Gong wrote:
> The Sparse tool reports as follows:
>
> drivers/base/node.c:239:1: warning:
> symbol 'dev_attr_line_size' was not declared. Should it be static?
> drivers/base/node.c:240:1: warning:
> symbol 'dev_attr_indexing' was not declared. Should it be static?
>
> These symbols (and several others) are defined by DEVICE_ATTR_RO(name) in
> CACHE_ATTR(name, fmt), and all of them are not used outside of node.c. So let's
> mark DEVICE_ATTR_RO(name) static to solve these complains from Sparse.
Why not fix them all at once? Why only one here?
thanks,
greg k-h
(Resend for the correct format. Apology from a TB amateur.)
On 2021/05/13 19:26, Greg Kroah-Hartman wrote:
> On Thu, May 13, 2021 at 07:07:16PM +0800, Ruiqi Gong wrote:
>> The Sparse tool reports as follows:
>>
>> drivers/base/node.c:239:1: warning:
>> symbol 'dev_attr_line_size' was not declared. Should it be static?
>> drivers/base/node.c:240:1: warning:
>> symbol 'dev_attr_indexing' was not declared. Should it be static?
>>
>> These symbols (and several others) are defined by DEVICE_ATTR_RO(name) in
>> CACHE_ATTR(name, fmt), and all of them are not used outside of node.c. So let's
>> mark DEVICE_ATTR_RO(name) static to solve these complains from Sparse.
>
> Why not fix them all at once? Why only one here?
Sorry for not making it clear enough. Actually the patch does fix them
all. Those symbols reported by Sparse are generated when two of the
following macros are expanded:
CACHE_ATTR(size, "%llu")
CACHE_ATTR(line_size, "%u")
CACHE_ATTR(indexing, "%u")
CACHE_ATTR(write_policy, "%u")
So one fix of the CACHE_ATTR's definition fixs them all.
>
> thanks,
>
> greg k-h
> .
>
.