Skip to contentSkip to conversation

zsmalloc: avoid unused-function warning

PATCH In review Arnd Bergmann 3 participants 3 messages Jan 17, 2023 – Jan 18, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 zsmalloc: avoid unused-function warning

From: Arnd Bergmann <[email protected]>

obj_allocated() can be called from two places that are each inside of an #ifdef. When both are disabled, the compiler warns:

mm/zsmalloc.c:900:13: error: 'obj_allocated' defined but not used [-Werror=unused-function]

Rather than trying to figure out the correct #ifdef, mark the trivial function as 'inline', which implies __maybe_unused and shuts up the warning.

Fixes 796c71ac728e ("zsmalloc: fix a race with deferred_handles storing")
---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +1 -1
index 723ed56d3fbb..9d27d9b00bce 100644
@@ -937,7 +937,7 @@ static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle,
 	return true;
 }
 
-static bool obj_allocated(struct page *page, void *obj, unsigned long *phandle)
+static inline bool obj_allocated(struct page *page, void *obj, unsigned long *phandle)
 {
 	return obj_tagged(page, obj, phandle, OBJ_ALLOCATED_TAG);
 }
Signature · 1 line
2.39.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Arnd Bergmann

obj_allocated() can be called from two places that are each inside of an #ifdef. When both are disabled, the compiler warns:

mm/zsmalloc.c:900:13: error: 'obj_allocated' defined but not used [-Werror=unused-function]

Rather than trying to figure out the correct #ifdef, mark the trivial function as 'inline', which implies __maybe_unused and shuts up the warning.

Fixes 796c71ac728e ("zsmalloc: fix a race with deferred_handles storing")
Acked-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

obj_allocated() can be called from two places that are each inside of an #ifdef. When both are disabled, the compiler warns:

Quoted 8 lines

mm/zsmalloc.c:900:13: error: 'obj_allocated' defined but not used [-Werror=unused-function]

Rather than trying to figure out the correct #ifdef, mark the trivial function as 'inline', which implies __maybe_unused and shuts up the warning.

Fixes 796c71ac728e ("zsmalloc: fix a race with deferred_handles storing")
Quoted 18 lines
---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zsmalloc.c +1 -2
index 723ed56d3fbb..9d27d9b00bce 100644
@@ -937,7 +937,7 @@ static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle,
        return true;
 }
 
-static bool obj_allocated(struct page *page, void *obj, unsigned long *phandle)
+static inline bool obj_allocated(struct page *page, void *obj, unsigned long *phandle)
 {
        return obj_tagged(page, obj, phandle, OBJ_ALLOCATED_TAG);
 }
--
Quoted 2 lines

2.39.0

Tricky one indeed - I definitely missed that. Thanks for the fix!