lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250120050536.sr4dgqz6b6qeov5k@vireshk-i7>
Date: Mon, 20 Jan 2025 10:35:36 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Gary Guo <gary@...yguo.net>
Cc: Alice Ryhl <aliceryhl@...gle.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Danilo Krummrich <dakr@...nel.org>, Miguel Ojeda <ojeda@...nel.org>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Boqun Feng <boqun.feng@...il.com>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <benno.lossin@...ton.me>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Trevor Gross <tmgross@...ch.edu>, Rob Herring <robh@...nel.org>,
	Dirk Behme <dirk.behme@...bosch.com>,
	rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rust: device: Replace CString with CStr in
 property_present()

On 18-01-25, 00:44, Gary Guo wrote:
> On Thu, 16 Jan 2025 09:25:17 +0100
> Alice Ryhl <aliceryhl@...gle.com> wrote:
> 
> > On Thu, Jan 16, 2025 at 6:26 AM Viresh Kumar <viresh.kumar@...aro.org> wrote:
> > >
> > > 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 <viresh.kumar@...aro.org>  
> > 
> > One nit below, but either way:
> > 
> > Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
> > 
> > > -    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 _) }  
> > 
> > If you use `name.as_char_ptr()` then you don't need the cast.
> 
> Isn't the cast not needed anyway with `as_ptr()`?

Yes that works too..

-- 
viresh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ