[PATCH v1] objtool/rust: add one more `noreturn` Rust function

FUJITA Tomonori posted 1 patch 1 month, 2 weeks ago
tools/objtool/check.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH v1] objtool/rust: add one more `noreturn` Rust function
Posted by FUJITA Tomonori 1 month, 2 weeks ago
Fix the follwoing warning:

rust/kernel.o: warning: objtool: _RNvXNtNtCs1ewLyjEZ7Le_6kernel3str9parse_intaNtNtB2_7private12FromStrRadix14from_str_radix()
falls through to next function _RNvXNtNtCs1ewLyjEZ7Le_6kernel3str9parse_intaNtNtB2_7private12FromStrRadix16from_u64_negated()

The commit 51d9ee90ea90 ("rust: str: add radix prefixed integer
parsing functions") introduces u64::from_str_radix(), whose
implementation contains a panic path for out-of-range radix values.
The panic helper is core::num::from_ascii_radix_panic().

Note that radix is derived from strip_radix() here and is always
within the valid range, so kernel never panics.

Fixes: 51d9ee90ea90 ("rust: str: add radix prefixed integer parsing functions")
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
 tools/objtool/check.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 3f7999317f4d..719ec727efd4 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -197,7 +197,8 @@ static bool is_rust_noreturn(const struct symbol *func)
 	 * as well as changes to the source code itself between versions (since
 	 * these come from the Rust standard library).
 	 */
-	return str_ends_with(func->name, "_4core5sliceSp15copy_from_slice17len_mismatch_fail")		||
+	return str_ends_with(func->name, "_4core3num22from_ascii_radix_panic")				||
+	       str_ends_with(func->name, "_4core5sliceSp15copy_from_slice17len_mismatch_fail")		||
 	       str_ends_with(func->name, "_4core6option13expect_failed")				||
 	       str_ends_with(func->name, "_4core6option13unwrap_failed")				||
 	       str_ends_with(func->name, "_4core6result13unwrap_failed")				||

base-commit: b927546677c876e26eba308550207c2ddf812a43
-- 
2.43.0
Re: [PATCH v1] objtool/rust: add one more `noreturn` Rust function
Posted by Miguel Ojeda 1 month ago
On Tue, Dec 23, 2025 at 12:39 PM FUJITA Tomonori
<fujita.tomonori@gmail.com> wrote:
>
> Fix the follwoing warning:
>
> rust/kernel.o: warning: objtool: _RNvXNtNtCs1ewLyjEZ7Le_6kernel3str9parse_intaNtNtB2_7private12FromStrRadix14from_str_radix()
> falls through to next function _RNvXNtNtCs1ewLyjEZ7Le_6kernel3str9parse_intaNtNtB2_7private12FromStrRadix16from_u64_negated()
>
> The commit 51d9ee90ea90 ("rust: str: add radix prefixed integer
> parsing functions") introduces u64::from_str_radix(), whose
> implementation contains a panic path for out-of-range radix values.
> The panic helper is core::num::from_ascii_radix_panic().
>
> Note that radix is derived from strip_radix() here and is always
> within the valid range, so kernel never panics.
>
> Fixes: 51d9ee90ea90 ("rust: str: add radix prefixed integer parsing functions")
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>

Applied to `rust-fixes` -- thanks everyone!

    [ Reworded typo. - Miguel ]

Cheers,
Miguel
Re: [PATCH v1] objtool/rust: add one more `noreturn` Rust function
Posted by Alice Ryhl 1 month, 1 week ago
On Tue, Dec 23, 2025 at 08:35:38PM +0900, FUJITA Tomonori wrote:
> Fix the follwoing warning:
> 
> rust/kernel.o: warning: objtool: _RNvXNtNtCs1ewLyjEZ7Le_6kernel3str9parse_intaNtNtB2_7private12FromStrRadix14from_str_radix()
> falls through to next function _RNvXNtNtCs1ewLyjEZ7Le_6kernel3str9parse_intaNtNtB2_7private12FromStrRadix16from_u64_negated()
> 
> The commit 51d9ee90ea90 ("rust: str: add radix prefixed integer
> parsing functions") introduces u64::from_str_radix(), whose
> implementation contains a panic path for out-of-range radix values.
> The panic helper is core::num::from_ascii_radix_panic().
> 
> Note that radix is derived from strip_radix() here and is always
> within the valid range, so kernel never panics.
> 
> Fixes: 51d9ee90ea90 ("rust: str: add radix prefixed integer parsing functions")
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Tested-by: Alice Ryhl <aliceryhl@google.com>