From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5B292D838E for ; Mon, 18 May 2026 18:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779130136; cv=none; b=raoxS2Lc0FCU+2JcFahHFgSJbCYlpUOEMBpUwG8JgcWy6pB3Xw1T60eWa3kI+3l6e6qWq2JjCWEVxq+lsNHcf6BSl71/s0t8B2CFIkQu71NocrrILStTQ1B6rdJArt4QpbY9OW7cR1EkFuRnDahnj31nr/ml/T/W1M5xUoDKdx8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779130136; c=relaxed/simple; bh=gsFKplm+aAGN2TTWLd5cPwWGFcZzpqzKphldaJZG+ck=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KihvluongUR+Yl8CI8nGbnMsdCJwEkiQk3O/r4Jqj7OewEv3II1Qs9MWIowlwTSl3GKSPGVG20YQ4j/Ep19sUx3GzDXJOkolJyls3KL2eiBa/TkFiwOCklbDxKlwIufpI/Rh3BE5kJPRtMqKkw6duYBGy0k4gmA4eYl3hgTCRZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SOcHnm8w; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SOcHnm8w" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-c7ffe8eeaf2so1090036a12.0 for ; Mon, 18 May 2026 11:48:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779130134; x=1779734934; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=4ssSrwxKRBuP3dItchoNca7SeIWgJGFfcgOMVqAx4Uo=; b=SOcHnm8wr3GhnDlSJDYoNg/eHoF0DSQTV/nTkAJz9L/iq1BQ2SXp0fMYcVwAGiUtSC 5sJ+2EMnrdMyeHVX1KT1fEJlM8wwt0B2K2wz5vsEuU8l2S5+B8Tkqon2kH5G5q5K+bFX 8Yiq2sxidT/AFnlJhrhKW1DkbeKh4t93QCjR3WOSiEIJaaqsE6yNzNePe9jNB+Biqnwj zMyNrf9BQzirCcdTbyKOznNniMbkwBZkQ0xrAOqLdCen2yDEPVqzRoJAwnkGsQJuiGyG ia/wobG5TmUej9Tg6ILHX6IwMY2K6u0Uai6SF26bqRDbtg5n+mxZgyr2RXFQL3FvwoC/ OKDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779130134; x=1779734934; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4ssSrwxKRBuP3dItchoNca7SeIWgJGFfcgOMVqAx4Uo=; b=PYDR6EYlHK+N0AiqepX2AgJLVKxXuoI/jJ6fpwaFFcBZvJG5Y6+/aEoaKWPP78tIaY hyq/RGCbwhiZGF8ZnC14hEpPz5NLUgPNGAPB/+H5GTYuzhAPZ2bCX6UnZWlE7n6G+DtX Dt8tp5aABFBWBCt59dmLDhMhvzNyD4rj48ZJjRR72fLgzMI60/y0JS30FkuaUNpcNUJx Nd4gnTMgwGIGqT8qi6e0yPRhzVgziXmTb/Ks2VEn7vWQRaQSibekZ96dtvvLZqeLCHdo w0cC/EDw94n/MWb8qQeKW6zQve4TAXEHzlaE9TBp9EdgPaWStO+7DuirGURZ1t+Hb/PG c/Vw== X-Forwarded-Encrypted: i=1; AFNElJ+c9TI3aiuGkcu9MlC9qkKgM1EoJWt0UpGtjZZnMQ22iuzbar+rNFpXYWhz6ugXLaYOqrdgumBV2oZQ8+A=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4Z7BCom8XvQkKlcaJxTPHOFwddhtDCsS/2JbFxDdL7xKdES/q Hyfg+2Ws352JwMjUO2KqZrVk4SCk484uB+Me+99DhG6NcnqcA4G1vnxD X-Gm-Gg: Acq92OEcMSt88PLLptSvzofBjSQZ/nVofmas3W4J3Y0l8GNUmG9jDK0m3W5k9s9phUc kSDBp7rH+2p4BQQpbQovviYhbi4ayCdqnrX46CqxDUUszGHAmY0QniZbNXSzXiuo8P7GR/pdW/3 g2oGlq1frVX/i6in+YAYRDMwObp/orPcHwMtM03OwX4xJcLLNz+ji8XBervUImUz0TDf+BhgJwR uHf+p4zqZK9kq5ouLNE0mKT7Ul9zF3C2dJYirgDqHD8yRTyROVH+8P7KRCccPQIt/3wR/YrxAEn nUig5ZPwM5cBy/0iV/axcrozOq2uCu9f1IGzQxMwsmCEBnAH25SEOxJVft/DT32YsxuYmukJkLB 4A6/W2B2C4eP4P63Mhl8J6adsYR3jrnYI16Inh4P0hXqGXYyYslQ7B5lUfz0zujhFJC0z7UQjaf kXaaDzg7xq5NsnUsY0PNQZxRZ83g== X-Received: by 2002:a17:902:76c1:b0:2ba:6ffa:bded with SMTP id d9443c01a7336-2bd7e9c5790mr132687625ad.37.1779130134122; Mon, 18 May 2026 11:48:54 -0700 (PDT) Received: from fedora ([49.36.193.91]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bd5d11b495sm165337945ad.69.2026.05.18.11.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 11:48:53 -0700 (PDT) Date: Tue, 19 May 2026 00:23:03 +0530 From: Ritvik Gupta To: Miguel Ojeda Cc: tglx@kernel.org, peterz@infradead.org, ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu, dakr@kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, skhan@linuxfoundation.org Subject: Re: [PATCH] rust: cpu: use `unsafe_precondition_assert!` Message-ID: References: <20260518174414.204573-1-ritvikfoss@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@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 Mon, May 18, 2026 at 07:51:28PM +0200, Miguel Ojeda wrote: > On Mon, May 18, 2026 at 7:40 PM Ritvik Gupta wrote: > > > > Replace `debug_assert!` invocations with > > `unsafe_precondition_assert!` in `from_i32_unchecked` > > and `from_u32_unchecked` unsafe functions. > > Thanks for the patch! > > This should mention that we are adding messages too. That could > actually be a second patch in the series to make it even clearer, but > it is not a big a deal either way (and perhaps `rustfmt` makes that > first patch not that clean due to the line wrapping anyway). > > Suggested-by: Miguel Ojeda > Link: https://github.com/Rust-for-Linux/linux/issues/1232 > > > -use crate::{bindings, device::Device, error::Result, prelude::ENODEV}; > > +use crate::{bindings, device::Device, error::Result, prelude::ENODEV, unsafe_precondition_assert}; > > We should probably put it in the prelude along the others -- the > easier it is to type, the better, to encourage its use. > > Do you want to add a first patch in the series doing that? > Sure! In v2 series, I'll add the first patch that adds `unsafe_precondition_assert!` to the prelude and second patch that uses it. > > + "CpuId::from_i32_unchecked requires a valid 'id' (i.e., `0 <= id < nr_cpu_ids()`)" > > This seems to mix Markdown backquotes with single quotes, and then > doesn't use backquotes in the first part. Could we make it consistent > if we are adding the messages? e.g. > > "`CpuId::from_i32_unchecked` requires a valid `id` (i.e., `0 <= id > < nr_cpu_ids()`)" > Sure, will fix :) > Sashiko has also spotted a copy-paste error in the one below. > > Cheers, > Miguel