kasan: fix variable 'tag' set but not used warning
diff mbox series

Message ID 20190307185244.54648-1-cai@lca.pw
State New
Headers show
Series
  • kasan: fix variable 'tag' set but not used warning
Related show

Commit Message

Qian Cai March 7, 2019, 6:52 p.m. UTC
set_tag() compiles away when CONFIG_KASAN_SW_TAGS=n, so make
arch_kasan_set_tag() a static inline function to fix warnings below.

mm/kasan/common.c: In function '__kasan_kmalloc':
mm/kasan/common.c:475:5: warning: variable 'tag' set but not used
[-Wunused-but-set-variable]
  u8 tag;
     ^~~

Signed-off-by: Qian Cai <cai@lca.pw>
---
 mm/kasan/kasan.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Andrey Konovalov March 8, 2019, 1:28 p.m. UTC | #1
On Thu, Mar 7, 2019 at 7:53 PM Qian Cai <cai@lca.pw> wrote:
>
> set_tag() compiles away when CONFIG_KASAN_SW_TAGS=n, so make
> arch_kasan_set_tag() a static inline function to fix warnings below.
>
> mm/kasan/common.c: In function '__kasan_kmalloc':
> mm/kasan/common.c:475:5: warning: variable 'tag' set but not used
> [-Wunused-but-set-variable]
>   u8 tag;
>      ^~~
>
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  mm/kasan/kasan.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> index 3e0c11f7d7a1..3ce956efa0cb 100644
> --- a/mm/kasan/kasan.h
> +++ b/mm/kasan/kasan.h
> @@ -163,7 +163,10 @@ static inline u8 random_tag(void)
>  #endif
>
>  #ifndef arch_kasan_set_tag
> -#define arch_kasan_set_tag(addr, tag)  ((void *)(addr))
> +static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
> +{
> +       return addr;
> +}
>  #endif
>  #ifndef arch_kasan_reset_tag
>  #define arch_kasan_reset_tag(addr)     ((void *)(addr))
> --
> 2.17.2 (Apple Git-113)
>

Reviewed-by: Andrey Konovalov <andreyknvl@google.com>

Thanks!

Patch
diff mbox series

diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
index 3e0c11f7d7a1..3ce956efa0cb 100644
--- a/mm/kasan/kasan.h
+++ b/mm/kasan/kasan.h
@@ -163,7 +163,10 @@  static inline u8 random_tag(void)
 #endif
 
 #ifndef arch_kasan_set_tag
-#define arch_kasan_set_tag(addr, tag)	((void *)(addr))
+static inline const void *arch_kasan_set_tag(const void *addr, u8 tag)
+{
+	return addr;
+}
 #endif
 #ifndef arch_kasan_reset_tag
 #define arch_kasan_reset_tag(addr)	((void *)(addr))