From patchwork Wed Sep 11 22:52:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13801193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BE73EE57D7 for ; Wed, 11 Sep 2024 22:56:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA9E46B00AB; Wed, 11 Sep 2024 18:56:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A58D06B00AD; Wed, 11 Sep 2024 18:56:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B63B6B00AE; Wed, 11 Sep 2024 18:56:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6B30D6B00AB for ; Wed, 11 Sep 2024 18:56:50 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2CFE5C16E7 for ; Wed, 11 Sep 2024 22:56:50 +0000 (UTC) X-FDA: 82553968980.25.9FD4718 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 8B8C9100002 for ; Wed, 11 Sep 2024 22:56:48 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Hlamu4iR; spf=pass (imf05.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726095304; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jfo4V10e6lOjfznTpyWD06S1WMnImc8oGefa3gyzVcQ=; b=6ZzZjUDGJBh3oAERFNfuvDu1boNwEByuzik77pUHzR9Ho9uRVcdCTy0K7kqW2FlLJhskwX 3zsc6kawndet9hWGNX+i4lI/0Fy9kavyF/vxJliyDO3HFILmj3gDf5l6rKwm4qQ46/z6qC mtBuZxSiVUPkHSbZ13bNonVQJ53F5vs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726095304; a=rsa-sha256; cv=none; b=bdkXFP5et1YMwYizyGjqL0shEsW1p5JV9/5vkesvDmxOparrSxJnfGqEuArXIL1ZKm1/yT DxWXUL0X+WJJBuR7hySH0zUNKEM7WAdwEx+2d+P4QhxvubVmJK8rRH3IhFgZuLXwF9YL6O j1ypI8OJcn2B4VUd5wugrXffFSRw058= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Hlamu4iR; spf=pass (imf05.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 234EB5C076E; Wed, 11 Sep 2024 22:56:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77EDDC4CECD; Wed, 11 Sep 2024 22:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726095407; bh=F2SiwlBtvDarApJOsx0M5Yh8m55DamKxmrKOHUpHf/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hlamu4iRv8xXSCkHAmar3KUNSPO3lkPYrPcPHu4IrAsbykCYVQpH0HcvRJJRZ0DHz XKpcM0mxEYFkl5S5WNATEcoL7Xs/iePmQhT1297x1nCybn3BwHGf9F8MwGHo1tF/re jyta5/E9VxSboNN95jYSIk5Krd7cpYjbyH+ePtE8st+cbUKNNS0G7EBY91R3VXZDou lt4MjcfAfxT2vFOVb5ZZaCHOvI5mp/oVMw5lME9XhehHaThcjPHWBshnWqF+FvwLUL zGZpYuNdVNupA6fpDQh6MD3xpcFe03UbJdkstToGDU7BpmtfXiTsnv2BjmKcVnv7f8 zi2EzgqaloJFA== From: Danilo Krummrich To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, akpm@linux-foundation.org Cc: daniel.almeida@collabora.com, faith.ekstrand@collabora.com, boris.brezillon@collabora.com, lina@asahilina.net, mcanal@igalia.com, zhiw@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com, airlied@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org, Danilo Krummrich Subject: [PATCH v7 20/26] rust: error: check for config `test` in `Error::name` Date: Thu, 12 Sep 2024 00:52:56 +0200 Message-ID: <20240911225449.152928-21-dakr@kernel.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911225449.152928-1-dakr@kernel.org> References: <20240911225449.152928-1-dakr@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8B8C9100002 X-Stat-Signature: 1rxkifti1zta9gkbjjdhkpkp8upo6c45 X-HE-Tag: 1726095408-791033 X-HE-Meta: U2FsdGVkX1/vNNYMhIb2K683PhKmuG6rADL9ny27NssD9py7ASqI2vu+X+NqB1bscmqmn3El/8NRO4s+hLAXRUkKrHpbt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TAtqJVZRAB9wijSQIjmox4N0OTgxw1rWnx/Svtdsg33ZjAB5eEWk63clJj+eo+7xlLpbie0XNrMQPNRQqU+4GGk18MK24vGqrRJG9jm87Q8dbJc1JXDtTRBhk/IWNGOWtKSX8uqtTXoXhU6a0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Additional to `testlib` also check for `test` in `Error::name`. This is required by a subsequent patch that (indirectly) uses `Error` in test cases. Reviewed-by: Alice Ryhl Reviewed-by: Benno Lossin Signed-off-by: Danilo Krummrich Reviewed-by: Gary Guo --- rust/kernel/error.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 81b4fc5cf21e..b71fdd0f54c2 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -143,7 +143,7 @@ pub(crate) fn to_ptr(self) -> *mut T { } /// Returns a string representing the error, if one exists. - #[cfg(not(testlib))] + #[cfg(not(any(test, testlib)))] pub fn name(&self) -> Option<&'static CStr> { // SAFETY: Just an FFI call, there are no extra safety requirements. let ptr = unsafe { bindings::errname(-self.0) }; @@ -160,7 +160,7 @@ pub fn name(&self) -> Option<&'static CStr> { /// When `testlib` is configured, this always returns `None` to avoid the dependency on a /// kernel function so that tests that use this (e.g., by calling [`Result::unwrap`]) can still /// run in userspace. - #[cfg(testlib)] + #[cfg(any(test, testlib))] pub fn name(&self) -> Option<&'static CStr> { None }