[PATCH] rust: device: Use as_char_ptr() to avoid explicit cast

Viresh Kumar posted 1 patch 11 months ago
rust/kernel/device.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] rust: device: Use as_char_ptr() to avoid explicit cast
Posted by Viresh Kumar 11 months ago
Use as_char_ptr() to avoid explicit cast.

Suggested-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Rebased over:

https://lore.kernel.org/all/e97dcbe0418cc1053fb4bcfac65cc02a0afcdf78.1737005078.git.viresh.kumar@linaro.org/

 rust/kernel/device.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
index c775266ae164..db2d9658ba47 100644
--- a/rust/kernel/device.rs
+++ b/rust/kernel/device.rs
@@ -185,7 +185,7 @@ unsafe fn printk(&self, klevel: &[u8], msg: fmt::Arguments<'_>) {
     /// Checks if property is present or not.
     pub fn property_present(&self, name: &CStr) -> bool {
         // SAFETY: By the invariant of `CStr`, `name` is null-terminated.
-        unsafe { bindings::device_property_present(self.as_raw().cast_const(), name.as_ptr() as *const _) }
+        unsafe { bindings::device_property_present(self.as_raw().cast_const(), name.as_char_ptr()) }
     }
 }
 
-- 
2.31.1.272.g89b43f80a514
Re: [PATCH] rust: device: Use as_char_ptr() to avoid explicit cast
Posted by Alice Ryhl 11 months ago
On Thu, Jan 16, 2025 at 9:34 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> Use as_char_ptr() to avoid explicit cast.
>
> Suggested-by: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

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