Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp538428rdb; Tue, 16 Jan 2024 08:03:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFiBGe5Y/oQFGqg6PaHEuAK7vxDNbheVDMCaaYfp94gFibGe10Rzow2Vzc0n2rG1/IPCSY X-Received: by 2002:ae9:e318:0:b0:783:28f6:8170 with SMTP id v24-20020ae9e318000000b0078328f68170mr7586355qkf.27.1705420997831; Tue, 16 Jan 2024 08:03:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705420997; cv=none; d=google.com; s=arc-20160816; b=oMLdmdXCuz/+8hv7c7Bnq76e1FhJYQ3NsOnpD2Mb+FSU6N0POrKA3h7DGZsrwqLfK/ w8+7gV3OeVd/pCx6HAVYFX/7Z4xT5K4pwmZXRJj+ZnYX1tqf8+JQCGIe6dyT3QQkXGK8 ATjzz//Zv/D2o6rWRgb8U1gLFs2A0+m26gEeRBKO9S0ywqRcnRKH6Saw2rZWrh+ArOId 9HF7pdlYjAGWzAl62c8YR7SYHThGJdrBCb/rnBsWl7rQB9Oqcuin2t+SrC9rqpBxO3rN FxhE8nhFvwjzzK8mxHtn9hqHpnJMP0icha3JCQfJYZagLOW9QxVUeyeBEuo53PLTpWDL CeCg== ARC-Message-Signature: i=1; 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=Bb349fvwXSjnN4V0GLzjJRdZzoRZLmEwtKL7jY3CLSU=; fh=mB5qiQ7ps5IWvjuQS9+zcxjK3ZInVolb8UwIN1mvAmg=; b=nbi02NyCZ3hOTjnVXFEep9RdpphxrkhLfVyltfdMkRolmf2pxuca6pU9QxTUwYjjzQ dmCvM0fQ6OGZQCTXNixgsuTWOlAJY988hLkiLDtqhwWVRhMfoKvY/iUu52c6y3ysIMT6 /fYCEKtSw7gU6gkRzeFjt17G4IFCbpycQjkdkYGm/dzuZhBh6dVBqXMMgTTFYJISAkCF xwys80cCnDEmvo9rXceCgoutiDmEqILucJ7HzqjF4GmeVKsircDIUJRGT9K40m/H8ZDt pzu1IdWRBHQOt28th/mK/xbThoUt2obE+69NkF5GpuighVs6Y58XKIFFfmWT1H4Fv0fs E/iw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-27554-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27554-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d20-20020a05622a15d400b00429a6f45c12si10235562qty.557.2024.01.16.08.03.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 08:03:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27554-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-27554-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27554-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 EA6511C23717 for ; Tue, 16 Jan 2024 16:03:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 577B71CA82; Tue, 16 Jan 2024 16:02:55 +0000 (UTC) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.133]) (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 F025C1C686; Tue, 16 Jan 2024 16:02:52 +0000 (UTC) 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 1MeToK-1qpL9E40VY-00aWQh; Tue, 16 Jan 2024 17:02:37 +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 02/13] rust: error: move unsafe block into function call Date: Tue, 16 Jan 2024 17:01:27 +0100 Message-ID: <20240116160141.165951-3-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-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:8YpdJM1GEeWDxH67CiH/gY2p2t5FekIWFaebx3JG/FApIvD6c+1 KA1ivQpbnXVGPZeHY18lF7JbGHwSuJRGTYFEfs4t8pO1LTRhw2gArE1+9Nghc4PRRgOns+U IQ+7ns++opvOiuh7FmD9yXxaLBMiDMRoWbO0ri95uXOGonyDeAeDsqBN8Oayq0vJd+rqdf9 Ni4CnrD/TGCtSaogYzKFQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:vfE4pxrJzRA=;T6tpxL0/72IvcsGh63L8yn0ff9A en6NnaOJkZzpWwHGTP1pOi+MM9TVMmCJpOz/NvS6h9DdGFy03ClTT+MorjaXDpdw6NIx4JVlP TOT+8ZY8pu/9PPwvsKOtMvzv72GjDAio2dYXQ4el/F+l1RVOnNbGbpWc5tAD8NpMrdW4+IjIw 98lJzIPkODHjOZ2GC1MflMf+YpcNBQsFQ1ruzzRIAHAC/rLjzXqSXMVCYXtnPeJKaVqIMX6K4 8xB5zdZHCBLm0cwUFufFVtQU1vWxpGUp1xr8a2CUsdVe6D+QqQVZDHupPYPXL/w9DrnKAHk2g eqyque/ZqUQBQ0Q4V26zxjcOW0Ct1nHDrY06SZJ7JhYEKaf7aCE/p9zdxNcywEzXq2p36UKVo ItqQa+MwHZbrG6AZreYne3g4JTtkAaC9M4sWMyiFWpKvXe9y54Ituvw3x29n5QZMtNll3Ezge aJmBY4XulN5wa+76YGhaXeLmsuU6plPyYWycoBgG8u2NuHmjoGBEVQLEzeZllweWrRSA7/BOq WbORVUU/pL461S8YUOrSbwTYqaMEdjPLDLvRQju7qDGf478O8XMC9LW5MPW6/yEJs+I5CuQp1 HJeax00F/Me8wooTp9AG24DEMVjBINVSxZy/Aco90gowOcNwjG/SAh4siOstSjALc98kIbG2h r419+NVaYPMCGcM6nSHcf/5OW59og0kk7HyruPO96KcCyDGy8PKbQIyg0SlDE8K8Fu1ACM5Rp vTTfk9dq2KJYjG/PeBxM3CAKHgOwJC9VWvsvujFS6bcPBZ2e19K3AfwqJBDd14XptY7Oiqinl OcOZS0NE1nLQe3YtVIbn/KkuaGkc7EqApKXYGscg9nzHTFd/FYGLNCo05DCBs5kw64+BGScW3 h6skzvWUQCoZaRPif6kgfLjDRyCZuQU5Jgd0= The `from_err_ptr` function is safe. There is no need for the call to it to be inside the unsafe block. Signed-off-by: Valentin Obst --- rust/kernel/error.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 4f0c1edd63b7..6f6676bc0eb9 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -265,12 +265,7 @@ pub fn to_result(err: core::ffi::c_int) -> Result { /// index: u32, /// ) -> Result<*mut core::ffi::c_void> { /// // SAFETY: FFI call. -/// unsafe { -/// from_err_ptr(bindings::devm_platform_ioremap_resource( -/// pdev.to_ptr(), -/// index, -/// )) -/// } +/// from_err_ptr(unsafe { bindings::devm_platform_ioremap_resource(pdev.to_ptr(), index) }) /// } /// ``` // TODO: Remove `dead_code` marker once an in-kernel client is available. -- 2.43.0