From: Viresh Kumar Date: Thu, 16 Jan 2025 05:26:21 +0000 (+0530) Subject: rust: device: Replace CString with CStr in property_present() X-Git-Tag: v6.14-rc1~55^2~1 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=e1cd24af8ff2ad7e26e1711be3d7bd72eef24279;p=linux-block.git rust: device: Replace CString with CStr in property_present() The property_present() method expects a &CString currently and will work only with heap allocated C strings. In order to make it work with compile-time string constants too, change the argument type to &CStr. Signed-off-by: Viresh Kumar Reviewed-by: Alice Ryhl Link: https://lore.kernel.org/r/e97dcbe0418cc1053fb4bcfac65cc02a0afcdf78.1737005078.git.viresh.kumar@linaro.org Signed-off-by: Greg Kroah-Hartman --- diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs index eadc6160a4be..c6823decbb2e 100644 --- a/rust/kernel/device.rs +++ b/rust/kernel/device.rs @@ -6,7 +6,7 @@ use crate::{ bindings, - str::CString, + str::CStr, types::{ARef, Opaque}, }; use core::{fmt, ptr}; @@ -183,8 +183,8 @@ impl Device { } /// Checks if property is present or not. - pub fn property_present(&self, name: &CString) -> bool { - // SAFETY: By the invariant of `CString`, `name` is null-terminated. + 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 _) } } }