Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp572935rdb; Tue, 23 Jan 2024 08:08:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfw9gT4V6Q/c7wtPGpM8ZGYhrkkh0726KudLhgxD5/YJla7ZIjdFETrRMnEq10+JyGxcDo X-Received: by 2002:a05:622a:118d:b0:42a:2205:ed94 with SMTP id m13-20020a05622a118d00b0042a2205ed94mr1189023qtk.78.1706026085214; Tue, 23 Jan 2024 08:08:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706026085; cv=pass; d=google.com; s=arc-20160816; b=GdQJehDaLU6LMVcrxx2KeGTvgAGGFwQYeEoGkx/w0Z9Y0Bbh257CBOpO2zqXz9bcgS w+nQ3VuTYjZ2bXXM8OVGgdTdLom54ENbTiEOVOUELs/NDfaosFGQSz4nDMsdYE7XXkHC LxnwGOab9ksdFfSttlsHwh5NYTociL3qlntGoc+qDra+KR5rEFp+29GIqlqAz6JPUmHW unNES1fIHAGqzVTLvqnpn57W2kyfUVPHTzMZ33t/4XYRMMRfdJeQg0A9ktZIjoeA3WDC UdpJzuLxO8Bl6k+L+dwRsTPHnC/bh/3e03+2c4WFKWzz5A5WRON/isgj1N3RrS66wElo stZQ== 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=3yUQPmlAgiw03cBaxiw8FcQ0h0YHyCEjLnQKAe+fxMg=; fh=BZI9iWTaEf0O3fXVlcMygnOLgsZaFpsfuA9TcLqdYG4=; b=QS7Auw0t5SxfppYLsV/i6vZM+p0HiJrlzxJ2i1SLgzehXf/Yh3+D34p/5UOlqGHpm8 JPeQ8fCy2th7D+uKc9BqQ8WlHeoCQvz2JnKG/eoOJIqkx8jVgsX6sbDDMqFaMVPHcFgj PMefYBLQePXjP3taD5kJO3ogmAcQrIO7652bDeFdY4HVKC0nIXK7h4CiRIXR6nPl889S zYJ+SIloFZWMMBgQ9MT2SA33fqNFKaD6i1SvCi/C3s1Xoqs3Ond7fc2cJhDb8uZ50AOz QJ4661jU6ApcsoqPSyMCevJod923vmyblb9m4Gn0jux6/mTBdLeVrOAlmlOywviqhXKE yu7A== 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-35622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35622-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 o9-20020a05622a008900b0042a35cc88b4si6518610qtw.54.2024.01.23.08.08.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 08:08:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35622-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-35622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35622-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 DCF0B1C238E1 for ; Tue, 23 Jan 2024 16:08:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEB98664DF; Tue, 23 Jan 2024 16:06:56 +0000 (UTC) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) (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 586906166E; Tue, 23 Jan 2024 16:06:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706026016; cv=none; b=nyypNh7TNCoZx0MAMBBzlkcAXYE147U5DBGYQggWIlZfq0ZVCtC0bHnqtiiroyKeEEQLNG9OXrX/HzAYfkcDao2X8cUakszzWc7TtCWhZi+MsA/UVCBVIEhzM3SIfD051IFFnnpURADo9s3tuloYk28fD0u18dtb1muRK8NnkNc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706026016; c=relaxed/simple; bh=+hqW3hOQC1UxvdWfn9TZu3+fIZ7vvE+96H8K/qkpMIg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l2ZGD0GrSHJJFUn8ni6Exea8+KGGBZ6MYZQ079Sfu4utVnknmZfDx8e8cMNVnCESpsT6sb58YUTX/k9pbMeVV5y9W0meJmCkb9frRuEU7lx+7EpPtf8zpW5bNvmvpRp37bbnw8hVpX/K2Is+htwvKTzh2drPZE57u0j0IaeyIV0= 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.17.10 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 ([95.223.130.98]) by mrelayeu.kundenserver.de (mreue106 [213.165.67.113]) with ESMTPSA (Nemesis) id 1N33ZD-1qy6RS2jwz-013OUg; Tue, 23 Jan 2024 17:06:43 +0100 From: Valentin Obst To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 06/12] rust: str: move SAFETY comment in front of unsafe block Date: Tue, 23 Jan 2024 17:06:41 +0100 Message-ID: <20240123160642.125285-1-kernel@valentinobst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123150112.124084-1-kernel@valentinobst.de> References: <20240123150112.124084-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:kkN8nkXFa/+Hos8xuVkzUCkfnQm83AX9LM0fqlu6ufKA1n6bf8O fDOu/W245ZOO3bxg1ZxOjfH79yvO+QF8AooaTY6iw9PjLiYxTmqyNvNIcn71GYfsNTbsurI gd9IazbpuqpzwB3Pi5WruGqT8LUUufy0CK7Vny2rw8uq6ysgNcN6oRf7TVYQI5Syb+YmCAH KOcm4J6PT92OtwpvFZj/A== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:UXzJXFTNxhQ=;cigvECPexeR2yYWYYtRlxnddXJ6 uUuC7zyc0G9/wix6gcrdC7KEtbWMeFKzssrRHli5z4UlFn0UNoJ1WuF98fKFmNlYjMx47bos0 k1uPNIXPGaHB515jcrN93YXGHA2zlk187NkpHT1zlQbzxPtPkBZZCw/PT006GpZ7oJ17bR3/6 SrV86T+WRZBjoXxj2JZ8D/9ZrNB3IPeDhNtPVSpZB/m7OmOLK/0b9sr9MgpOl6joC1O/2AEEL 3i3eWtoWc7KIj3U0NWnyrirRII/JezCsrE48ZYrBvhkMXyGcECKA8pVHjEMuSMqw3+6TMInCl 3Jvs6f5UdV1eP2g69l7e+uBeug/sRpnNU5BajfEyilkOdkI6TLMoo6EBbivEOValh/CAXnQfY TI+Y0ow2u+kXmizqRdSlLU6Zr2o7lnV2cPLL35MxQZbpSXK9ChdyiGu/Lz+r0kGmFXgsO9tNX 6cwAlJJW2N9EivRWNE7Sug2jmn2l0e+g08cTYi10LUcbJUiysJEsFONBPpNbwkO/BQK+XEeVS HIVqW28zSUS6UW/jNRiNTyNirD2F+Ztr86mh44D0wG/l9rQq4JEuoZH2frQ+gP3jnU1nxZjur UxuAzcvZ7L4DOTtJkXHfcyR2hnLygWhKtwPwVJ+8vUX/nnNhMVZp0DXza9OYV8Qo+NFSGhAf4 bjZOiQ9iKN4muNIKJUQaci8r51eDuxu+OE0S3GNFIYRbC37Nr9ROvObaxE1i5zOFl7isjJEXB T31yEA5ZcGGg0WFUFMVVGr2jXFJlD15kjmJUF4/YIyO2w6gja72JsQ6vjpThXXGEpR1tC1XNY dkrkmGZJ2AVv91Pb2f3Z44cg83hsI/ZVgd6GIuufvk7UkH4swQp5jHLM5Oo0Y1RSnHRT4xVLt vc79mNqvYvfN2Pg== 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 Reviewed-by: Trevor Gross Reviewed-by: Martin Rodriguez Reboredo --- 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