Commit 0dac8cf4 authored by Tamir Duberstein's avatar Tamir Duberstein Committed by Miguel Ojeda
Browse files

rust_binder: use `core::ffi::CStr` method names



Prepare for `core::ffi::CStr` taking the place of `kernel::str::CStr` by
avoiding methods that only exist on the latter.

This backslid in commit eafedbc7 ("rust_binder: add Rust Binder
driver").

Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Signed-off-by: default avatarTamir Duberstein <tamird@gmail.com>
Link: https://patch.msgid.link/20251018-cstr-core-v18-4-9378a54385f8@gmail.com


Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent 5aed9677
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ pub(super) fn command_string(i: usize) -> &'static str {
        // SAFETY: Accessing `binder_command_strings` is always safe.
        let c_str_ptr = unsafe { binder_command_strings[i] };
        // SAFETY: The `binder_command_strings` array only contains nul-terminated strings.
        let bytes = unsafe { CStr::from_char_ptr(c_str_ptr) }.as_bytes();
        let bytes = unsafe { CStr::from_char_ptr(c_str_ptr) }.to_bytes();
        // SAFETY: The `binder_command_strings` array only contains strings with ascii-chars.
        unsafe { from_utf8_unchecked(bytes) }
    }
@@ -81,7 +81,7 @@ pub(super) fn return_string(i: usize) -> &'static str {
        // SAFETY: Accessing `binder_return_strings` is always safe.
        let c_str_ptr = unsafe { binder_return_strings[i] };
        // SAFETY: The `binder_command_strings` array only contains nul-terminated strings.
        let bytes = unsafe { CStr::from_char_ptr(c_str_ptr) }.as_bytes();
        let bytes = unsafe { CStr::from_char_ptr(c_str_ptr) }.to_bytes();
        // SAFETY: The `binder_command_strings` array only contains strings with ascii-chars.
        unsafe { from_utf8_unchecked(bytes) }
    }