Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nicolas@fjasle.eu>,
	linux-kbuild@vger.kernel.org
Subject: Re: [PATCH] modpost: Warn about unused module namespace imports
Date: Thu, 23 Jan 2025 17:50:37 +0200	[thread overview]
Message-ID: <Z5JlTd-qCif4a5W2@smile.fi.intel.com> (raw)
In-Reply-To: <20250123110951.370759-2-u.kleine-koenig@baylibre.com>

On Thu, Jan 23, 2025 at 12:09:50PM +0100, Uwe Kleine-König wrote:
> Symbols can be exported in namespaces and to make use of such symbols,
> the namespace has to be explicitly imported. Importing a namespace
> without actually using one of its symbols is likely a mistake.
> 
> There are a few offenders for an x86_64 allmodconfig build, so the
> warning is (for now) only enabled for W=1 builds.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> ---
> Hello,
> 
> one of the offenders is drivers/pwm/pwm-raspberrypi-poe.c (
> 
> 	WARNING: modpost: module pwm-raspberrypi-poe imports namespace PWM, but doesn't use it.
> 
> ). The issue there is that on x86_64 CONFIG_RASPBERRYPI_FIRMWARE is
> always disabled and so devm_rpi_firmware_get() returns always NULL which
> makes raspberrypi_pwm_probe return an error before the pwm functions are
> used. So the compiler optimizes out all references to pwm functions and
> the warning triggers. I didn't look into the other problems to check if
> these are similar half-false positives.
> 
> Still I think this is a useful check?

This will require to add a number of ugly ifdeffery to the kernel code like

MODULE_FOO();
#if ...
MODULE_IMPORT_NS();
#endif

I am definitely not okay with that.

Maybe you should introduce the MODULE_IMPORT_NS_IF_REACHABLE() or so to hide
this or whatever equivalent there?

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-01-23 15:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-23 11:09 [PATCH] modpost: Warn about unused module namespace imports Uwe Kleine-König
2025-01-23 15:50 ` Andy Shevchenko [this message]
2025-01-30  6:38   ` Masahiro Yamada

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=Z5JlTd-qCif4a5W2@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    --cc=u.kleine-koenig@baylibre.com \
    /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