lib: sort: make it explicitly non-modular
PATCH 1/1 lib: sort: make it explicitly non-modular
The Makefile currently controlling compilation of this code is:
lib/Kconfig.debug:config TEST_SORT
lib/Kconfig.debug: bool "Array-based sort test"
and...
lib/Makefile:obj-y += bcd.o div64.o sort.o [...]
...meaning that it currently is not being built as a module by anyone.
Lets remove the couple traces of modular infrastructure use, so that when reading the code there is no doubt it is builtin-only.
Since module_init translates to device_initcall in the non-modular case, the init ordering becomes slightly earlier when we change it to use subsys_initcall as done here. However, since it is a self contained test, this shouldn't be an issue and subsys_initcall seems like a better fit for this particular case.
We also delete the MODULE_LICENSE tag since that information is now contained at the top of the file in the comments.
---
[since this recently appeared in next via the akpm feed, I'm
fine with this commit being squashed into the original. ]
lib/sort.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
lib/sort.c +3 -4
@@ -1,5 +1,6 @@/* * A fast, small, non-recursive O(nlog n) sort for the Linux kernel +* License: GPL * * Jan 23 2005 Matt Mackall <[email protected]> */
@@ -106,7 +107,7 @@ EXPORT_SYMBOL(sort);#ifdef CONFIG_TEST_SORT #include <linux/slab.h> -#include <linux/module.h> +#include <linux/init.h> /* a simple boot-time regression test */ #define TEST_LEN 1000
@@ -143,7 +144,5 @@ static int __init test_sort_init(void)kfree (a); return err; } - -module_init (test_sort_init); -MODULE_LICENSE ("GPL" ); +subsys_initcall (test_sort_init);#endif
Signature · 1 line
2.11.0
Quoted 10 lines · Paul Gortmaker
The
Makefilecurrently controlling compilation of this code is:lib/Kconfig.debug:config
TEST_SORT
lib/Kconfig.debug: bool "Array-based sort test"and...
lib/Makefile:obj-y += bcd.o div64.o sort.o [...]...meaning that it currently is not being built as a module by anyone.
Perhaps allow it to be a module?
Besides that perhaps rename to something like test_sort.c ?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · [Re: [PATCH] lib: sort: make it explicitly non-modular] On 18/01/2017 (Wed…
Quoted 5 lines · Paul Gortmaker
The
Makefilecurrently controlling compilation of this code is:lib/Kconfig.debug:config
TEST_SORT
lib/Kconfig.debug: bool "Array-based sort test"
Quoted 7 lines
Quoted 5 lines
and...
lib/Makefile:obj-y += bcd.o div64.o sort.o [...]...meaning that it currently is not being built as a module by anyone.
Perhaps allow it to be a module?
If anything, I'd argue the other way and say we shouldn't be further polluting Kconfig space with more super specific options. Instead something more generic like CONFIG_ENABLE_BOOT_SELF_TESTS that at least could be shared.
There is no real value in making something a module when it could just as easily be thrown out as __init code/data.
Quoted 2 lines
Besides that perhaps rename to something like
test_sort.c?
The sort.c was not added just for the test code ; it already existed for the sort code itself.
Paul.
--
Quoted 4 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
How about the patch ("lib: move sort self-test into a separate file") [1] ?
regards,
Felix.
Quoted 1 line · Felix Kostenzer
How about the patch ("lib: move sort self-test into a separate file") [1] ?
The Kconfig did not change, so forking out the content to a separate file doesn't change the fact that it uses module.h for a chunk of code that can't be a module. That still remains to be addressed.
Paul.
--
Quoted 5 lines
regards,
Felix.