From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56DD21F8F07; Wed, 8 Jan 2025 12:15:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736338501; cv=none; b=X7c+XpxBlOfyH3MKh3WwksBYtPuC819PakyQ0bkLOGNTlQfRx1c83bnrRtiqKav8D42fVAIOyS+jXsWYDByyLmAzb9WZoLeR/qFeJj9hB5yDtXNRhPEgMvWlo7RT1CrDcSDve94+k/3InXnTD2uI88dIJ2CMcIwqJsZy0TtL9Uc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736338501; c=relaxed/simple; bh=ucoyG4O7Dg6LGWBoP+zrTqY/WNLhwkS+ljmKUYtFkpw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WivulywaoFypx3zpEbPbDbvuDcIZyk62VYkJgRoTYE1FAGN3AuHNW8iYhUPdGkoBF8loJzsqjTLGokmnUso9wlAWzj4HOUm3sKpnRboFtDT/B/4DGhNmKlk8GrupJolYHlSsVISs4D05YnhRzQcHfZzMv3lYRAkentWGDfN55kU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yMu5AMsf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="yMu5AMsf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B215C4CEDD; Wed, 8 Jan 2025 12:15:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1736338500; bh=ucoyG4O7Dg6LGWBoP+zrTqY/WNLhwkS+ljmKUYtFkpw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yMu5AMsfCoik22t1xZqxwdzrftYY/pOso6SckSTL55S490ZVHEnXrXFtHleUKXnyv qCWP05JKWHukuwmLlWWUyvEDRpSNwiM4LwmFL4/pdmVO3l0Q5ncZYksrEWyRJzNTvQ f3bnqFNLPn+vaDXurdWRh4iE6hlqisSAKISXyq0E= Date: Wed, 8 Jan 2025 13:14:58 +0100 From: Greg Kroah-Hartman To: Alice Ryhl Cc: Viresh Kumar , "Rafael J. Wysocki" , Miguel Ojeda , Danilo Krummrich , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , linux-pm@vger.kernel.org, Vincent Guittot , Stephen Boyd , Nishanth Menon , rust-for-linux@vger.kernel.org, Manos Pitsidianakis , Erik Schilling , Alex =?iso-8859-1?Q?Benn=E9e?= , Joakim Bech , Rob Herring , linux-kernel@vger.kernel.org Subject: Re: [PATCH V6 04/15] rust: device: Add few helpers Message-ID: <2025010829-kabob-herbs-8ce6@gregkh> References: <429b7539f787ad360cd28fd1db6dc3d6c1fe289d.1736248242.git.viresh.kumar@linaro.org> <2025010734-march-cultivate-bd96@gregkh> <20250108110242.dwhdlwnyjloz6dwb@vireshk-i7> <2025010835-uncover-pamphlet-de5b@gregkh> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Jan 08, 2025 at 12:55:38PM +0100, Alice Ryhl wrote: > On Wed, Jan 8, 2025 at 12:52 PM Greg Kroah-Hartman > wrote: > > > + /// 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. > > > + unsafe { bindings::device_property_present(self.as_raw() as *const _, name.as_ptr() as *const _) } > > > > I hate to ask, but how was this compiling if the const wasn't there > > before? There's no type-checking happening here? If not, how are we > > ever going to notice when function parameters change? If there is type > > checking, how did this ever build without the const? > > > > confused, > > Rust auto-converts `*mut` pointers to `*const` when necessary. Ah, so it's magic :) thanks for the explaination. greg k-h