From: Andrew Morton <akpm@linux-foundation.org>
To: Dan Williams <dan.j.williams@intel.com>
Cc: <peterz@infradead.org>, <linux-kernel@vger.kernel.org>,
<linux-cxl@vger.kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Dave Jiang <dave.jiang@intel.com>,
"David Lechner" <dlechner@baylibre.com>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Andy Shevchenko <andriy.shevchenko@intel.com>
Subject: Re: [PATCH v2] cleanup: Fix "unused function" warnings with conditional guards
Date: Wed, 17 Sep 2025 16:06:44 -0700 [thread overview]
Message-ID: <20250917160644.6f85ca40b1e352fa117dabf9@linux-foundation.org> (raw)
In-Reply-To: <20250904225010.1804783-1-dan.j.williams@intel.com>
On Thu, 4 Sep 2025 15:50:10 -0700 Dan Williams <dan.j.williams@intel.com> wrote:
> While the warning could simply be moved to W=2 [1], there is some small
> value, and not much cost to fixing it.
>
> The issue, Andy reports that the "lock_timer" scheme in
> kernel/time/posix-timers.c, with its custom usage of
> DEFINE_CLASS_IS_COND_GUARD(), results in:
>
> kernel/time/posix-timers.c:89:1: error: unused function 'class_lock_timer_lock_err' [-Werror,-Wunused-function]
> 89 | DEFINE_CLASS_IS_COND_GUARD(lock_timer);
>
> ...with a clang W=1 build. This warning has some value because it can catch
> when a conditional guard is defined, but not evaluated by a conditional
> acquisition helper like scoped_cond_guard() or ACQUIRE().
>
> Andy also reports that plain DEFINE_GUARD() also encounters this warning:
>
> drivers/pwm/core.c:54:1: error: unused function 'class_pwmchip_lock_err' [-Werror,-Wunused-function]
> 54 | DEFINE_GUARD(pwmchip, struct pwm_chip *, pwmchip_lock(_T), pwmchip_unlock(_T))
>
> ...which *is* a false positive.
>
> Fix those 2 issues by teaching scoped_cond_guard() to check for error
> values, and otherwise teach the DEFINE_GUARD() path to mark the conditional
> helpers as __maybe_unused.
Warning about unused static inlines in .c files is just annoying. If
the function is unused in all possible configs (man GREP(1)) then OK.
Otherwise, let it be.
> Alternatively just merge the suggestion in [1], and call it a day.
>
> Link: http://lore.kernel.org/20250813152142.GP4067720@noisy.programming.kicks-ass.net [1]
lgtm, unless we think this (your) patch improves the code for other reasons?
next prev parent reply other threads:[~2025-09-17 23:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 22:50 [PATCH v2] cleanup: Fix "unused function" warnings with conditional guards Dan Williams
2025-09-17 23:06 ` Andrew Morton [this message]
2025-09-17 23:21 ` dan.j.williams
2025-09-18 19:21 ` Andy Shevchenko
2025-09-18 19:26 ` dan.j.williams
2025-09-22 6:33 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250917160644.6f85ca40b1e352fa117dabf9@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=andriy.shevchenko@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dlechner@baylibre.com \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox