From: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
To: Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Sami Tolvanen <samitolvanen@google.com>,
Daniel Gomez <da.gomez@samsung.com>,
Brendan Higgins <brendan.higgins@linux.dev>,
David Gow <davidgow@google.com>, Rae Moar <rmoar@google.com>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: [PATCH 3/3] kunit: test: Drop CONFIG_MODULE ifdeffery
Date: Thu, 12 Jun 2025 16:53:56 +0200 [thread overview]
Message-ID: <20250612-kunit-ifdef-modules-v1-3-fdccd42dcff8@linutronix.de> (raw)
In-Reply-To: <20250612-kunit-ifdef-modules-v1-0-fdccd42dcff8@linutronix.de>
The function stubs exposed by module.h allow the code to compile properly
without the ifdeffery. The generated object code stays the same, as the
compiler can optimize away all the dead code.
As the code is still typechecked developer errors can be detected faster.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
lib/kunit/test.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 146d1b48a0965e8aaddb6162928f408bbb542645..019b2ac9c8469021542b610278f8842e100d57ad 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -759,7 +759,6 @@ void __kunit_test_suites_exit(struct kunit_suite **suites, int num_suites)
}
EXPORT_SYMBOL_GPL(__kunit_test_suites_exit);
-#ifdef CONFIG_MODULES
static void kunit_module_init(struct module *mod)
{
struct kunit_suite_set suite_set, filtered_set;
@@ -847,7 +846,6 @@ static struct notifier_block kunit_mod_nb = {
.notifier_call = kunit_module_notify,
.priority = 0,
};
-#endif
KUNIT_DEFINE_ACTION_WRAPPER(kfree_action_wrapper, kfree, const void *)
@@ -938,20 +936,14 @@ static int __init kunit_init(void)
kunit_debugfs_init();
kunit_bus_init();
-#ifdef CONFIG_MODULES
return register_module_notifier(&kunit_mod_nb);
-#else
- return 0;
-#endif
}
late_initcall(kunit_init);
static void __exit kunit_exit(void)
{
memset(&kunit_hooks, 0, sizeof(kunit_hooks));
-#ifdef CONFIG_MODULES
unregister_module_notifier(&kunit_mod_nb);
-#endif
kunit_bus_shutdown();
--
2.49.0
next prev parent reply other threads:[~2025-06-12 14:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 14:53 [PATCH 0/3] module: make structure definitions always visible Thomas Weißschuh
2025-06-12 14:53 ` [PATCH 1/3] module: move 'struct module_use' to internal.h Thomas Weißschuh
2025-06-17 7:38 ` Petr Pavlu
2025-06-19 16:27 ` Daniel Gomez
2025-06-12 14:53 ` [PATCH 2/3] module: make structure definitions always visible Thomas Weißschuh
2025-07-07 19:11 ` Daniel Gomez
2025-07-08 9:32 ` Petr Pavlu
2025-07-11 6:29 ` Thomas Weißschuh
2025-07-11 13:24 ` Daniel Gomez
2025-07-08 9:39 ` Petr Pavlu
2025-06-12 14:53 ` Thomas Weißschuh [this message]
2025-06-17 7:44 ` [PATCH 3/3] kunit: test: Drop CONFIG_MODULE ifdeffery Petr Pavlu
2025-06-17 8:39 ` Thomas Weißschuh
2025-06-17 15:07 ` Petr Pavlu
2025-06-20 9:51 ` David Gow
2025-07-11 13:25 ` Daniel Gomez
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=20250612-kunit-ifdef-modules-v1-3-fdccd42dcff8@linutronix.de \
--to=thomas.weissschuh@linutronix.de \
--cc=brendan.higgins@linux.dev \
--cc=da.gomez@samsung.com \
--cc=davidgow@google.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=rmoar@google.com \
--cc=samitolvanen@google.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;
as well as URLs for NNTP newsgroup(s).