Message ID | 20240116220615.168083-1-kernel@valentinobst.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-28332-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp567201dye; Tue, 16 Jan 2024 14:50:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxYu3ykAtzTBFVVOfGrcLb0yMS2jY+b8J7jw+UQ8vL7l+3lEihKFhcrt83R7KhCcxf5MGj X-Received: by 2002:aa7:c24b:0:b0:558:da41:df4c with SMTP id y11-20020aa7c24b000000b00558da41df4cmr3953113edo.69.1705445429969; Tue, 16 Jan 2024 14:50:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705445429; cv=pass; d=google.com; s=arc-20160816; b=qbtxYyfBOlkxuAWBFB3HbzmdAxZHX0AeXN2vLP+WQPX4RR7beVOtoX8YD6MLK9V5Rb uiLX4Yd3aeDqg+6/OubOu8023Zl3ZVVl/9XJ4tuUFskLY4jmTDsrySq2xytMxGLB1Tin z4L2XCj/b9NLrmFpWyM9I1FKyWdTy0yFQB97DSl/rejZuoUoT9cMFdxqft4OWXTWWP2x I67MSutO3R7wfpgaIcKIey4XZcJCS8F9ZHVJc9QjCKtisZnfo7rTIvA2PB+KHemvZ1Bh bflkmh1gEhWG11UTviwkyioZvB6YSoExxIwNjJXJHYAmbvZzz8EokVX8POIgnbto1Wh3 8UVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from; bh=ODp54UIm9/ahCWvjtdorJeiMkpcIRZRjhKT3hZ1PNKc=; fh=mB5qiQ7ps5IWvjuQS9+zcxjK3ZInVolb8UwIN1mvAmg=; b=r/tKxgb6T4gbWcpPWI/k3n6WCJTMK1woFgiLNSNN7U/v/uEdxUgiBvCdjh2aBoYfTS 3Lgxh1K2y6fiHys6504n8IcXOLJ47YCiXJT/2VFxNlP011gZS++fHyPZhPxBhKeo8nrS vX29+YpIHYU0h1xetYxHP68qwpQLrnKhJmdUFCaDE32TW3z+AHHebgz3Yxe/QGtFkPvF X9rr4GD1pRkNy3VsPAe6R9b2++LH7qPm0SA/oO6Di+xm0qCtwBN5FwdDg8iyw10vLVlr w1p6Hj1GxiF3oecauePHPtakYjwE1soBnrXkJvob34WbhlU82Tvy5tx0BgH8E14wwkCA smmA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=valentinobst.de); spf=pass (google.com: domain of linux-kernel+bounces-28332-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28332-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p13-20020a05640243cd00b005597811e947si1492065edc.234.2024.01.16.14.50.29 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 14:50:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28332-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=valentinobst.de); spf=pass (google.com: domain of linux-kernel+bounces-28332-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28332-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3AC4C1F2B8D0 for <ouuuleilei@gmail.com>; Tue, 16 Jan 2024 22:36:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD16250242; Tue, 16 Jan 2024 22:06:39 +0000 (UTC) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) (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 6883C482C5; Tue, 16 Jan 2024 22:06:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.126.135 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705442798; cv=none; b=ncLpNUDP6rVBA7je8M67ZQTVg8omVdLPoziGLSyX90r/VpwOWxt3s6mqvmgHzhp0h8/RkXKc/57DoI/OWjgTM/t0zLvvt0qDCRVuDXdF2s0xPt0p3BLH/tI8sd5OydaR7/oYC/0Kag4lytsj+VYUOEwh/8vZ8mbt3kJ/cBVFPlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705442798; c=relaxed/simple; bh=qk5bZBH+v41bJbF9eA7PUNh+z+ew2nxhcrsQeadaNNY=; h=Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Type:Content-Transfer-Encoding: X-Provags-ID:X-Spam-Flag:UI-OutboundReport; b=HxBuy0+K+r3q8eiBESNUBRDIZ60i7EYGZb4IIUpwsSyDiMDyxH+VUDFWwZU371urm5vaqqC+K2mrmuzZuMCWxNnjGE+plE6rQ8w7OP0PsnjDf0v2zQxaXk9NIdvQiwO8ciGgJXmqVwHBFA3WotFalX6FHkCQe+MEkssbwgrkROI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=valentinobst.de; spf=pass smtp.mailfrom=valentinobst.de; arc=none smtp.client-ip=212.227.126.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=valentinobst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=valentinobst.de Received: from localhost.localdomain ([217.245.156.100]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MTRAS-1rZe8B0H0e-00TkmV; Tue, 16 Jan 2024 23:06:23 +0100 From: Valentin Obst <kernel@valentinobst.de> To: Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>, Wedson Almeida Filho <wedsonaf@gmail.com> Cc: Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= <bjorn3_gh@protonmail.com>, Benno Lossin <benno.lossin@proton.me>, Andreas Hindborg <a.hindborg@samsung.com>, Alice Ryhl <aliceryhl@google.com>, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Valentin Obst <kernel@valentinobst.de> Subject: [PATCH 06/13] rust: str: move SAFETY comment in front of unsafe block Date: Tue, 16 Jan 2024 23:06:08 +0100 Message-ID: <20240116220615.168083-1-kernel@valentinobst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116160141.165951-1-kernel@valentinobst.de> References: <20240116160141.165951-1-kernel@valentinobst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:92bNKdsjs75qSuvDF2FfcB++cPal267HLhMmtY/xJxJoC3ADGN1 Q0SezTBfAlV6TObTXq/zXit0+qvLYh5/dYlHlk1bPM2kICVcDSNmVON061S5cgGZpoknMuR a2yEumtbq/wshozvCHePnlT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IL-THRID: 1788289147120170653 X-GMAIL-MSGID: 1788289147120170653 |
Series |
rust: kernel: documentation improvements
|
|
Commit Message
Valentin Obst
Jan. 16, 2024, 10:06 p.m. UTC
SAFETY comments should immediately precede the unsafe block they
justify. Move assignment to `bar` past comment as it is safe.
Signed-off-by: Valentin Obst <kernel@valentinobst.de>
---
rust/kernel/str.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Jan 16, 2024 at 5:36 PM Valentin Obst <kernel@valentinobst.de> wrote: > > SAFETY comments should immediately precede the unsafe block they > justify. Move assignment to `bar` past comment as it is safe. > > Signed-off-by: Valentin Obst <kernel@valentinobst.de> > --- > rust/kernel/str.rs | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs > index 843ffeec9b3e..fec5c4314758 100644 > --- a/rust/kernel/str.rs > +++ b/rust/kernel/str.rs > @@ -191,9 +191,9 @@ pub fn to_str(&self) -> Result<&str, core::str::Utf8Error> { > /// ``` > /// # use kernel::c_str; > /// # use kernel::str::CStr; > + /// let bar = c_str!("ツ"); > /// // SAFETY: String literals are guaranteed to be valid UTF-8 > /// // by the Rust compiler. > - /// let bar = c_str!("ツ"); > /// assert_eq!(unsafe { bar.as_str_unchecked() }, "ツ"); > /// ``` > #[inline] > -- > 2.43.0 > > Reviewed-by: Trevor Gross <tmgross@umich.edu>
diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index 843ffeec9b3e..fec5c4314758 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -191,9 +191,9 @@ pub fn to_str(&self) -> Result<&str, core::str::Utf8Error> { /// ``` /// # use kernel::c_str; /// # use kernel::str::CStr; + /// let bar = c_str!("ツ"); /// // SAFETY: String literals are guaranteed to be valid UTF-8 /// // by the Rust compiler. - /// let bar = c_str!("ツ"); /// assert_eq!(unsafe { bar.as_str_unchecked() }, "ツ"); /// ``` #[inline]