[PATCH] kallsyms: Change func signature for cleanup_symbol_name()

Yonghong Song posted 1 patch 2 years, 3 months ago
kernel/kallsyms.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
[PATCH] kallsyms: Change func signature for cleanup_symbol_name()
Posted by Yonghong Song 2 years, 3 months ago
All users of cleanup_symbol_name() do not use the return value.
So let us change the return value of cleanup_symbol_name() to
'void' to reflect its usage pattern.

Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
 kernel/kallsyms.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

NOTE:
This patch needs to be applied after the following patch:
https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=33f0467fe069

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index e12d26c10dba..18edd57b5fe8 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -163,12 +163,12 @@ unsigned long kallsyms_sym_address(int idx)
 	return kallsyms_relative_base - 1 - kallsyms_offsets[idx];
 }
 
-static bool cleanup_symbol_name(char *s)
+static void cleanup_symbol_name(char *s)
 {
 	char *res;
 
 	if (!IS_ENABLED(CONFIG_LTO_CLANG))
-		return false;
+		return;
 
 	/*
 	 * LLVM appends various suffixes for local functions and variables that
@@ -178,12 +178,10 @@ static bool cleanup_symbol_name(char *s)
 	 * - foo.llvm.[0-9a-f]+
 	 */
 	res = strstr(s, ".llvm.");
-	if (res) {
+	if (res)
 		*res = '\0';
-		return true;
-	}
 
-	return false;
+	return;
 }
 
 static int compare_symbol_name(const char *name, char *namebuf)
-- 
2.34.1
Re: [PATCH] kallsyms: Change func signature for cleanup_symbol_name()
Posted by Kees Cook 2 years, 3 months ago
On Fri, 25 Aug 2023 13:20:36 -0700, Yonghong Song wrote:
> All users of cleanup_symbol_name() do not use the return value.
> So let us change the return value of cleanup_symbol_name() to
> 'void' to reflect its usage pattern.
> 
> 

Applied to for-next/hardening, thanks!

[1/1] kallsyms: Change func signature for cleanup_symbol_name()
      https://git.kernel.org/kees/c/76903a964874

Take care,

-- 
Kees Cook
Re: [PATCH] kallsyms: Change func signature for cleanup_symbol_name()
Posted by Song Liu 2 years, 3 months ago
On Fri, Aug 25, 2023 at 1:21 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>
> All users of cleanup_symbol_name() do not use the return value.
> So let us change the return value of cleanup_symbol_name() to
> 'void' to reflect its usage pattern.
>
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>

Reviewed-by: Song Liu <song@kernel.org>
Re: [PATCH] kallsyms: Change func signature for cleanup_symbol_name()
Posted by Nick Desaulniers 2 years, 3 months ago
On Fri, Aug 25, 2023 at 1:20 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>
> All users of cleanup_symbol_name() do not use the return value.
> So let us change the return value of cleanup_symbol_name() to
> 'void' to reflect its usage pattern.
>
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>

LGTM; thanks!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  kernel/kallsyms.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> NOTE:
> This patch needs to be applied after the following patch:
> https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=33f0467fe069
>
> diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> index e12d26c10dba..18edd57b5fe8 100644
> --- a/kernel/kallsyms.c
> +++ b/kernel/kallsyms.c
> @@ -163,12 +163,12 @@ unsigned long kallsyms_sym_address(int idx)
>         return kallsyms_relative_base - 1 - kallsyms_offsets[idx];
>  }
>
> -static bool cleanup_symbol_name(char *s)
> +static void cleanup_symbol_name(char *s)
>  {
>         char *res;
>
>         if (!IS_ENABLED(CONFIG_LTO_CLANG))
> -               return false;
> +               return;
>
>         /*
>          * LLVM appends various suffixes for local functions and variables that
> @@ -178,12 +178,10 @@ static bool cleanup_symbol_name(char *s)
>          * - foo.llvm.[0-9a-f]+
>          */
>         res = strstr(s, ".llvm.");
> -       if (res) {
> +       if (res)
>                 *res = '\0';
> -               return true;
> -       }
>
> -       return false;
> +       return;
>  }
>
>  static int compare_symbol_name(const char *name, char *namebuf)
> --
> 2.34.1
>


-- 
Thanks,
~Nick Desaulniers