From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from flow-a5-smtp.messagingengine.com (flow-a5-smtp.messagingengine.com [103.168.172.140]) (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 D39C91C5D7D for ; Fri, 24 Jul 2026 04:09:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.140 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784866143; cv=none; b=ZbAXvntScCHMWXCJXbCmWTg5dDbOp+yJfa/aWI92spmFHi3iilavFQBbQ9Vq6XHg/U07QQ8GI82iRbscc0NTqtFZmNwyCt+ArEvtJQRm1CgPmU1s4gC+IqI87TUGuBMrOS8HG7bqSG4lS/lrWajq3D8u9iMPh7Oo+QXn7dkOAP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784866143; c=relaxed/simple; bh=lCot1/K9G1s7zCTxWRlOJCyioFiarcg/8ENRIUOGFN8=; h=Date:Message-Id:To:Cc:Subject:From:In-Reply-To:References: Mime-Version:Content-Type; b=a/JIB3i3p29uL8gOvMkGuWMyJ3TWaZ44Tt5Vd3a3delH2KZef3TdsW/MOFLLRFD0QW2aUvrxoLu4LPz7zW4IktBrb0Wj8NlUPmkAwWyWRAKsODwebQguzVWTLEgSaIW650WzmZqgWQuKIrzYZbs6KBdTqKjXhQP3Mw5zO3OIQHk= 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=fBQCgD2T; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Brre2Ry5; arc=none smtp.client-ip=103.168.172.140 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="fBQCgD2T"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Brre2Ry5" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailflow.phl.internal (Postfix) with ESMTP id CDD9713801BD; Fri, 24 Jul 2026 00:09:00 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Fri, 24 Jul 2026 00:09:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flapping.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1784866140; x=1784869740; bh=gktvss8Nw6gWCwRMUXQNEfHkQ95oubJrjuB/dtEsxD0=; b= fBQCgD2T8woJGPX3vXzqYjEQNdMp4CKk5OFbYqyXCWjttnl2wDQywopXW2WjoNLi Ru6EbEO2y1NHuj8W69iCkl7vGWigxlJbebUkt2fawz0DIVTR1u70jTMPp+anQqwe 9SOfkYXMznUgy2CJWwSyROHJYCRQRT42uVcI0gBwfLtdK8L4Rfzobggii/6Dy0bQ daFuv+3sNsMho7xVYXWW3OA6lQ3g041tC7//h29dwFq0EZaHbhZqzLUkzkbGN5/p HR2VKlA07vYnrFcK9k0l+tYstmIFRG9XvqDuXR4BsYL5qkwLqkD6rU8cDA1RjCMr KIGEaf+A56MjetoMnjJnPg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1784866140; x= 1784869740; bh=gktv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epFJdB814EPisKU3qoD+muQ X-ME-Proxy: Feedback-ID: i51fe4b43:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 24 Jul 2026 00:08:56 -0400 (EDT) Date: Fri, 24 Jul 2026 13:08:53 +0900 (JST) Message-Id: <20260724.130853.1719089301624801198.tomo@flapping.org> To: gary@garyguo.net Cc: tomo@flapping.org, ojeda@kernel.org, a.hindborg@kernel.org, acourbot@nvidia.com, aliceryhl@google.com, bjorn3_gh@protonmail.com, boqun@kernel.org, dakr@kernel.org, daniel.almeida@collabora.com, lossin@kernel.org, tamird@kernel.org, tmgross@umich.edu, work@onurozkan.dev, rust-for-linux@vger.kernel.org, fujita.tomonori@gmail.com Subject: Re: [PATCH v1] rust: bug: prevent dead_code warning from warn_on!'s flags constant From: FUJITA Tomonori In-Reply-To: References: <20260720035510.4048145-1-tomo@flapping.org> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit On Fri, 24 Jul 2026 00:40:04 +0100 "Gary Guo" wrote: >> diff --git a/rust/kernel/bug.rs b/rust/kernel/bug.rs >> index ed943960f851..2fd7ee25abcb 100644 >> --- a/rust/kernel/bug.rs >> +++ b/rust/kernel/bug.rs >> @@ -123,9 +123,9 @@ macro_rules! warn_on { >> const _COND_STR: &str = file!(); >> >> if cond { >> - const WARN_ON_FLAGS: u32 = $crate::bug::bugflag_taint($crate::bindings::TAINT_WARN); >> + const _WARN_ON_FLAGS: u32 = $crate::bug::bugflag_taint($crate::bindings::TAINT_WARN); >> >> - $crate::warn_flags!(_COND_STR, WARN_ON_FLAGS); >> + $crate::warn_flags!(_COND_STR, _WARN_ON_FLAGS); > > Hmm, why bother adding a const for this rather than just invoke > > $crate::warn_flags!( > _COND_STR, > const { ... } > ) > > ? Ah, `(const { ... })` works. > Also, the proper fix would be to mark it as used in the `warn_flags` macro > that discard the expression. > > if false { > _ = $flags; > } Yeah, having the callee that discards the argument consume it is more logical than working around it at the caller. I'll send v2 shortly. The same reasoning applies to `$file`. Since there is no warning right now, I'll rename `_COND_STR` to `COND_STR` and consume `$file` in a separate patch for consistency.