From nobody Mon Dec 1 22:05:08 2025 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.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 75118277CBF for ; Mon, 1 Dec 2025 06:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764570363; cv=none; b=S8vINkKwYeX35DSMIPo6GyVhZxdq15RvbWjkzhPore7nvlfgBMF4PQqtvMWnc419JLltH9sPC7gBTz/Rc5UqnNvOuGvLO/RMu8v7VkUMvLC+EElo7RITwwXiMOx3dMr5d7camXTWw3wm7o7QyHMs7R6diDs/xu3wp1/wZeE6rjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764570363; c=relaxed/simple; bh=A7ro82FM1edXs+/+ownwRip2IpfdNYYd10dBFRcg04A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TXgGJxhDB1QcfiUrzgzTmNdbD6BN1NurhNWOkdrreiUuZpR2pAJPuEkCYZ+18THPdTSk1m1yvLfi2ULL7HG72Lf0uS7QY9yJq0G4MPqED8at8IGiXjkFh/RlMfdH3WZMnoxxDmA+xJYUH2fd4+gegFKyS0QJ5D8SjF8yTDufNds= 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=YLE23lch; arc=none smtp.client-ip=209.85.214.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="YLE23lch" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-29586626fbeso47762265ad.0 for ; Sun, 30 Nov 2025 22:26:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764570362; x=1765175162; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=l24zPOGXcv+MrIeCvAd8PjXoruUegqSyldxNvKkr/XQ=; b=YLE23lchMsRdVZjaJuzjCQSLZ4UkJlWKKtdV3Wul/1l9txy+qJOVYr7vEZdd4h8762 bcTpK8t2oy8y9Z6sreCqhM5J0EwJ2qMe4s2T1EQHNTDRrZT2beyTAscJtAVE4uzBK+lr ITa812mQdOzoq79L1UxU81YMFRR31SzOV4jHYQipv8JX3g8lCKvvl3/dPfInJks8z4Y1 BkwQOpQyTeR2x+fVfyw4XKOyfoqavqHTEsET8JAGxAB1SYFKu6jgJF+OSfkke4pxDIwd Ddti4ByGoBlvZd6L5mrQdo1iTSq4Xffhg9QiDD6/Y4W66p7JbRowo/yKZabRYILtSu2/ 2x6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764570362; x=1765175162; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=l24zPOGXcv+MrIeCvAd8PjXoruUegqSyldxNvKkr/XQ=; b=Rv+rt3UZ2aOZ2vIhElWMcumZh4bNqsfdEQUldXTRQkPECiZmIEO+oPSORXSHY7KK+i 83e92XENXmBF8eqb0EM3T5l2PgXG7utlYEOhCbFgAG1HbbM8hMzbJF91bDHJmUtqIWfg wS8iNanaIuOWNMhB6/zXaklTXPw+AgjH0EZIduLeUxG4gUFCI6U7nhd//jpMbWT1RBPW 2hpysm/HStgU9vSqoFyMoS2VRJDdfsNxMGbb6QAFs5z5O9G6Co39ffWfdRmuPkiCdmqD EM5XC8dqxqA/YL2Do+4fhGk57tFhcpUlUrfWypr//ld1T5ZQGlB1vR6bIC3kzqaHYucT WBgw== X-Forwarded-Encrypted: i=1; AJvYcCXEGp2sGoeCzajIPjH/buh7NIHcbCSUJrPuJtRf4AGXXp8/nxONlMnF4M1qLz+OJxZycBIsDeTO769SB+0=@vger.kernel.org X-Gm-Message-State: AOJu0Yzw1J3UhHAPWgi9J5kKFDAzA3CrlI3/hojyYrx0biNlAOGA6x4/ 0mxsFJ8TS1hzUyiTxTpcYA/nuDWrDPy7ACqpOAvUuqgJ46tggCN+6dVv X-Gm-Gg: ASbGncuvXi3UJfd6eZE8La2Zc8IKK575gjePNZlH5Rv5Fsylk0mAtjRuYP8NFvqeYWL ocxxvdkORP5chE+CV5HqSUlZA8g4CIaEvCNzuHwSpqCtuwpVVLlEzq899sso3E3aS2V00LBUYZ4 ovL4ibUn6yJ4d30dR/8xPWOTJOWF14XSRx2ixeus9evJsJPuViOzNqGu9iCLQpl07a9f/svk8hR mD54U73oKmslWD8GX9SH89qJNLDlLuXqxEG0wfmb+i3F+d0PJFZqfkVNiPjKCeZNfPnebJwsPUz 48acUwtwyeB/HpDIS2fUfUXvGGuc8NUKwYwDJcyiNQTREuf0rB8OajbcKZaXypZP16iOmXufrKs OTLf84+64TiYR8f059UPJY8dfeEgGSCIYPrRQT009RwWlA/p9sIz/dRhbHzXi5ynyAKoGKvfm/E sSRFPtc13dWXo0HFsly6DpUnXirRJHQtEusso= X-Google-Smtp-Source: AGHT+IG3sV9Qt5fQfg3gW3GI/3a0A9MchGOswH6LWYTCdRWwXvAjK1iXO/TaAfq8zC1KmnmmrSyuRQ== X-Received: by 2002:a17:903:298e:b0:296:549c:a2b with SMTP id d9443c01a7336-29b6be8be11mr433516675ad.3.1764570361740; Sun, 30 Nov 2025 22:26:01 -0800 (PST) Received: from localhost.localdomain ([49.213.140.88]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29bceb7bccbsm109831945ad.100.2025.11.30.22.25.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Nov 2025 22:26:01 -0800 (PST) From: Hsiu Che Yu To: Alexandre Courbot Cc: Hsiu Che Yu , Miguel Ojeda , Yury Norov , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rust: num: bounded: add safety comment for Bounded::__new Date: Mon, 1 Dec 2025 14:25:16 +0800 Message-ID: <20251201062516.45495-1-yu.whisper.personal@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The `__new` constructor only performs a bounds check and stores the value in the wrapper type. It does not perform any unsafe memory operations, so it does not need to be marked as `unsafe`. Reported-by: Miguel Ojeda Closes: https://github.com/Rust-for-Linux/linux/issues/1211 Signed-off-by: Hsiu Che Yu --- rust/kernel/num/bounded.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust/kernel/num/bounded.rs b/rust/kernel/num/bounded.rs index f870080af8ac..cde1b8ba6880 100644 --- a/rust/kernel/num/bounded.rs +++ b/rust/kernel/num/bounded.rs @@ -284,6 +284,9 @@ impl Bounded /// /// The caller remains responsible for checking, either statically or = dynamically, that `value` /// can be represented as a `T` using at most `N` bits. + /// + /// **Note**: This function is not marked as `unsafe` because it perfo= rms no memory-unsafe + /// operations itself. const fn __new(value: T) -> Self { // Enforce the type invariants. const { --=20 2.43.0