diff mbox series

zsmalloc: avoid unused-function warning

Message ID 20230117170507.2651972-1-arnd@kernel.org (mailing list archive)
State New
Headers show
Series zsmalloc: avoid unused-function warning | expand

Commit Message

Arnd Bergmann Jan. 17, 2023, 5:04 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 mm/zsmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sergey Senozhatsky Jan. 18, 2023, 12:39 a.m. UTC | #1
On (23/01/17 18:04), Arnd Bergmann wrote:
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Nhat Pham Jan. 18, 2023, 7:27 p.m. UTC | #2
On Tue, Jan 17, 2023 at 9:05 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Nhat Pham <nphamcs@gmail.com>
> ---
>  mm/zsmalloc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 723ed56d3fbb..9d27d9b00bce 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -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);
>  }
> --
> 2.39.0
>
Tricky one indeed - I definitely missed that. Thanks for the fix!
diff mbox series

Patch

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 723ed56d3fbb..9d27d9b00bce 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -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);
 }