[PATCH v3 0/8] selftests/mm: Add compiler flags and fix found warnings

Andrew Morton akpm at linux-foundation.org
Fri Aug 22 17:42:59 PDT 2025


On Fri, 22 Aug 2025 13:20:57 +0500 Muhammad Usama Anjum <usama.anjum at collabora.com> wrote:

> Recently, I reviewed a patch on the mm/kselftest mailing list about a
> test which had obvious type mismatch fix in it. It was strange why that
> wasn't caught during development and when patch was accepted. This led
> me to discover that those extra compiler options to catch these warnings
> aren't being used. When I added them, I found tens of warnings in just
> mm suite.
> 
> In this series, I'm adding these flags and fixing those warnings. In the
> last try several months ago [1], I'd patches for individual tests. I've
> made patches better by grouping the same type of fixes together. Hence
> there is no changelog for individual patches.

I think it would be best to avoid adding warnings to selftests which
aren't present in the main kernel code.  If only to avoid surprising
people over what isn't permissible in selftests/.

In particular, there's an expectation that we can do

#else
static inline int some_stub(type1 arg1, type2 arg2)
{
}
#endif

without warning.  We do this extensively.

Also, please be aware that there's already a patch in mm-new which
centralizes selftests' __maybe_unused definition.
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-centralise-maybe-unused-definition-in-kselftesth.patch



More information about the linux-riscv mailing list