Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp47467rdb; Tue, 16 Jan 2024 14:36:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhYTkfWV0gEFxJwR/zZBbPwNCkBt8hPaenYp8abMtIroOeHVU3bFXzTNxqAQpJu1DE7TfP X-Received: by 2002:a0c:e3d4:0:b0:681:7878:5443 with SMTP id e20-20020a0ce3d4000000b0068178785443mr615215qvl.131.1705444600825; Tue, 16 Jan 2024 14:36:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705444600; cv=pass; d=google.com; s=arc-20160816; b=wmQufMRw/xk97n433pxO20enZCE3aDufna7N8HS18FQ3wwvxpz/TGz5lHvL4KyKIIi Mf1zTDytlc9DT4VPTQNPQGWpKHKEdJlNSmlVQkQ5GH7fhReCmIsC3Rp756Ao2KOBxb3p btm8aCMZmy69fJFiZfi80qr2MUluiTsdWJzGtNInSrZBWI273vpJ3OI36lknN+SRaB2C jZdn8PAYHoeF9lny02Zrrmv+pYjWMtQ48JoSmNu3g3/ifljo8spBODeZ3twOc5ocdXY/ oHreFLnPmjMTycTVHn4nijMWBgARxL7exf+HcTp7V/1MJRYpoSg8PlBWQB52fhIkBfy5 4Gfw== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28332-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x17-20020a0cb211000000b0067f610371dcsi10405905qvd.137.2024.01.16.14.36.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 14:36:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28332-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=valentinobst.de); spf=pass (google.com: domain of linux-kernel+bounces-28332-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28332-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 943951C254ED for ; Tue, 16 Jan 2024 22:36:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7E744F883; Tue, 16 Jan 2024 22:06:38 +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 To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho Cc: Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Valentin Obst 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: List-Subscribe: List-Unsubscribe: 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/wshozvCHePnlTDJGeXEJGfhNEevVJRwW1ruSQWCtm32mt7xQq3WCo1NvzPaih rL/R6VUX7Dn8WKCH7eupQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:IDkEWhURD7c=;ReOjbrZ1lRUgApOj8G512ld2rTl aQs7HB5kgSZXS6lHwfPaeXaHxoZ2OpWlmXyb04o8nQo8QtRcdjzvERRCOyv6t2vpknYmWf/Rh z9cjszLazIMHfX4PE5pQssyfLVD5v4XaTzMazV2Voo9juG8U/oOATNg2uwGnvlGjlxo6YUR9K Hb9o53W2yCkumbzLM3gqrtGJZeJVO8cmcwwl28KDQBXh/YEWWWAtiWp41rHq2auHVAlVSyIZo YrHjJpgOa1g7+Qr06o4UMyHj3/SNxEe77QCwCrHy0FTttlRPh3fS1DLmW4P5ai83VHK2IOnRP YoB0iJ1eHGHwfgIvPfqrd/j6EJUm0aKjPlyXdY86kh+YUk6OZhYv7hLvUCoNxbAiDxu8zJeSM SQzQw1wPlP6Ktlpl4eCCw2yAoCk8POJN0lWSlPRFDxldxkzDiCHLXQ/V8Vay6S/kQRWz9mt6e ibwo6WzLSqYg4x4WxPAfZJhMUamd7ige1FWWYijTTUJazH0nJiSTVWfYipaul6+e1wPq/S6rv NUuT+PUF+cAKZlvqx5/pF1uad1auLfgdtawVH+4sAyT6TljbD6aBEJ8Whcbn37FyjjRH0T4XI Z0tjlVKjGzxAnFEClmooSG3Yrosh3gr26aA8nxichmw1Cbd3MppzpmSmZJc1P0mB5RZ4m7rmK JURAwDyOG/0fz/jgwCz6LaU7Op+TqtRNIk9byzpOz2o8eeOGVpECgUaUOIz0ANaLiWWHzRq6S 1pcMfC5HUmvEM/NY2UkCoN9rPpZwFAJ9Yr1E4O1RTClipec0ViW3v7qWABY1vbUSRcitcOx2n wvIt3M4HoHMTJxrcOS+j/f6nbFt1Q5rtZGR9er3yrixeDnKbelUM+SUYtu1z+qPzHV3sMnpqF r50BBcY5rmvXpBw== 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 --- 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