From patchwork Mon Aug 12 18:23:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13760937 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 F16D0C3DA7F for ; Mon, 12 Aug 2024 18:26:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D3366B00A1; Mon, 12 Aug 2024 14:26:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75B9A6B00AE; Mon, 12 Aug 2024 14:26:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FB226B00CA; Mon, 12 Aug 2024 14:26:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 372A06B00A1 for ; Mon, 12 Aug 2024 14:26:02 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EBB5F1C1DF0 for ; Mon, 12 Aug 2024 18:26:01 +0000 (UTC) X-FDA: 82444422522.02.7F1AE61 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id CFCDB160030 for ; Mon, 12 Aug 2024 18:25:59 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=p6j+mJpZ; spf=pass (imf08.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723487067; 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=4Rd5AInb2DngjvLHcLtOVGOOZeTvJsEDnW1UeOyjq70=; b=7S0oPOrQlBv3Dt1srXitcFHreGl2HN0nCcOD2mnl7EWaqlDI66l6pGXZaIr2f6n+KlHCCk T/if7+9+1fs2MIB9gB+khOEz9zcac4gWs9Yp4LTlwVY3fPmcVZNBWxF9t/psJgNc2aKnaA VUaztDHh++KCwc01MV0zS1OISuZD/EM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=p6j+mJpZ; spf=pass (imf08.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723487067; a=rsa-sha256; cv=none; b=0GOWKEmg7cVLQ+jsmwfLfBO/LNlwo/s1GBF1Xz+PRlutoYMfuIfYInKBGJpDxjwZuYV/Wd MuvapPOc0djf1ENRc5tiT639skIfzL5oSHSGf28he773d/HlULi1Gza2GXxUhDvS2dbHMc w9MhXsBPtMQy+h18yvHYPGN14csxMvE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 3C02BCE1034; Mon, 12 Aug 2024 18:25:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B5DDC4AF09; Mon, 12 Aug 2024 18:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723487156; bh=2F6Eq8ZEErgwGsu4sxTQuCutTP6qKEaQ1vvV8Sy7t1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p6j+mJpZtX+GQyemhh1YN3z+WuLKkO07HkID9hB60cEgOmMMs5DJr4cHKl1pgGPeR 2zIpFnJHzziufgeTVg+xA5uce22bQeLWbfLDPV5oiSEq+SNKklaaVdlEROb6c81rIQ Q8CDN418goWJaq0ttWBuLX4VyQ7c24iY7eQ9d+3oJ7Gp9lREGXADM9jAIKJ3qTMJq4 eV4yUFZsIj6KTKDzj/3ZaX3CItDMBhnlUIwrWi7BQ819hVr6+KgPLw13G5v6DLQ6K8 tTVj59KMhsXhTZd8JhgIDl+XQxhKQiN4I+WuM2Eg0yLzJBA4rY+drE+cbFM0avdu4N sSJ85j4Uw23OQ== 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 v5 20/26] rust: error: check for config `test` in `Error::name` Date: Mon, 12 Aug 2024 20:23:06 +0200 Message-ID: <20240812182355.11641-21-dakr@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812182355.11641-1-dakr@kernel.org> References: <20240812182355.11641-1-dakr@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CFCDB160030 X-Stat-Signature: gcaiz7paamudqtqf6f7hbyjbbsnfymfx X-Rspam-User: X-HE-Tag: 1723487159-512748 X-HE-Meta: U2FsdGVkX1/95h/azFzjFms83Sf+ffrX7z2hyxgZV/OhHki13xjLpB7C20LD8dHwPtfd49CWTb9Gf0Rq+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N/zbW5fNjdUj58zc6j1HWqLnYNDqIzeIpsC35sP6Ss0/NrysYPDj/TDeJdyA5qh+BaGSIsJ5O4lo1uyJSjtthSXYqX0IeQjaYO2OnC0ikdy0jvnZrjc9B9MMGOuZhl+wKS7nD64GvXMdKW26yVt/rCNZWY/xRmlNLmyIYSagc8= 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 Signed-off-by: Danilo Krummrich --- 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 2d012cc3881a..7adf889b9526 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -140,7 +140,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) }; @@ -157,7 +157,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 }