From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from flow-b7-smtp.messagingengine.com (flow-b7-smtp.messagingengine.com [202.12.124.142]) (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 8F18838F945; Fri, 7 Aug 2026 11:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.142 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786101884; cv=none; b=kLgoWXZlZq0H9GdyF2K6Y7jcw3MjVYNyF3WQrDiy5lIOSBiGCsRRcZnTyzRLUopTU+vM0rO1pBh3q0BU5AmnHD+9UQPC0NHycinntIqkdklxivvPa4eQb+Z26IYUumhQezB8hQSnxnBM7doi0+HEyp3PldEX48nfFqT3JGGQV1Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786101884; c=relaxed/simple; bh=1bJrQdoDJJlnYPeQhM1gZaO3AapKytI+Anwh/AUi2a8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=O0Oi1WWDvislaEiCbhiscIvXPIu3Yj5a7BG6Vgt7zhRh3obEzHl8vfyY128HlSNPbfXKbDvDsVlVCrJGOFZLrnVjPKEslHh97ieAiJpnc/uZdFbLadVINh37RUvsoz7XRPO9u3LsMpnPi1sjoHIueeEVlAgzKbwJ47d+N42nFng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=flapping.org; spf=pass smtp.mailfrom=flapping.org; dkim=pass (2048-bit key) header.d=flapping.org header.i=@flapping.org header.b=QoQ8eDhV; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=GTD+qGdy; arc=none smtp.client-ip=202.12.124.142 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=flapping.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flapping.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flapping.org header.i=@flapping.org header.b="QoQ8eDhV"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="GTD+qGdy" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailflow.stl.internal (Postfix) with ESMTP id 6430B13000BF; Fri, 7 Aug 2026 07:24:41 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 07 Aug 2026 07:24:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flapping.org; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to; s=fm1; t=1786101881; x=1786105481; bh=0xEKjxQ5miH9a4/azPF9P KTqxsokQze1z8Q/PdPKxt4=; b=QoQ8eDhVLC9Vt7hKPuaqemZcFoAs0Kiw/pfVv AB/NaSwrnmJNzaMm6aWNNmTpOJgADcW/FOf31DetNWXEuhtA4Pwur+nCi7krFfJP 0clPKzU1Juy0tU2SD9GaYACMOWqYQY91HUkh7LneK2qKXsFMuugctjQNmymJVCvy pyka5SBTMo2FS3avpYoxxP9sn4l32uew0ypBnXI8zAJ/C9KoWJqWNSpeFF+/Wph+ MZfLlTsRzYcjVHAh9PqllkndPH+iKpxJtDWEUWXoaqCUJDt1W6z1o7yZyDrfOx67 gRYlgJ0xvcspVEzFdnAnzDOuEwQ09zwEUVBnEIA97A5/QPA2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1786101881; x=1786105481; bh=0xEKjxQ5miH9a4/azPF9PKTqxsokQze1z8Q /PdPKxt4=; b=GTD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proxy: Feedback-ID: i51fe4b43:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 7 Aug 2026 07:24:36 -0400 (EDT) From: FUJITA Tomonori To: ojeda@kernel.org Cc: a.hindborg@kernel.org, acourbot@nvidia.com, aliceryhl@google.com, bjorn3_gh@protonmail.com, boqun@kernel.org, dakr@kernel.org, daniel.almeida@collabora.com, gary@garyguo.net, lossin@kernel.org, tamird@kernel.org, tmgross@umich.edu, work@onurozkan.dev, rust-for-linux@vger.kernel.org, david@davidgow.net, FUJITA Tomonori , stable@vger.kernel.org Subject: [PATCH v2] rust: bug: fix warn_on macro build error on UML Date: Fri, 7 Aug 2026 20:24:27 +0900 Message-ID: <20260807112427.1039056-1-tomo@flapping.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: FUJITA Tomonori Callers that go through `kernel::prelude` have `CStrExt` in scope, but code inside the `kernel` crate imports explicitly and may not. Using `warn_on!` from such a module fails to build on UML, which is the only configuration where `warn_flags!` needs a C string pointer rather than an inline asm bug entry: error[E0599]: no method named `as_char_ptr` found for reference `&ffi::CStr` in the current scope --> linux/rust/kernel/bug.rs:83:49 | 83 | $crate::c_str!(::core::file!()).as_char_ptr(), | ^^^^^^^^^^^ | ::: linux/rust/kernel/time.rs:427:9 | 427 | warn_on!(self.nanos < 0); | ------------------------ in this macro invocation | = help: items from traits can only be used if the trait is in scope = note: this error originates in the macro `$crate::warn_flags` which comes from the expansion of the macro `warn_on` (in Nightly builds, run with -Z mac) help: trait `CStrExt` which provides `as_char_ptr` is implemented but not in scope; perhaps you want to import it --> linux/rust/kernel/time.rs:27:1 | 27 + use crate::str::CStrExt; Call the method through its fully qualified path, which resolves without any import at the expansion site. Cc: stable@vger.kernel.org Fixes: dff64b072708 ("rust: Add warn_on macro") Signed-off-by: FUJITA Tomonori --- v2 - Use the fully qualified path to CStrExt::as_char_ptr() instead of the free function v1: https://lore.kernel.org/rust-for-linux/20260801022501.722493-1-tomo@flapping.org/ --- rust/kernel/bug.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kernel/bug.rs b/rust/kernel/bug.rs index ed943960f851..40633a516a8f 100644 --- a/rust/kernel/bug.rs +++ b/rust/kernel/bug.rs @@ -80,7 +80,7 @@ macro_rules! warn_flags { // with a valid null-terminated string. unsafe { $crate::bindings::warn_slowpath_fmt( - $crate::c_str!(::core::file!()).as_char_ptr(), + $crate::str::CStrExt::as_char_ptr($crate::c_str!(::core::file!())), line!() as $crate::ffi::c_int, $flags as $crate::ffi::c_uint, ::core::ptr::null(), base-commit: 075b74841bd0065a3bda3440873c747938e69b68 -- 2.43.0