Add lib/glob.c
Subsystems (2)
PATCH 1/2 Add lib/glob.c
In reply to a message not in the archiveThis is a helper function from drivers/ata/libata_core.c, where it is used to blacklist particular device models. It's being moved to lib/ so other drivers may use it for the same purpose.
This implementation in non-recursive, so is safe for the kernel stack.
---
Finally rescued this from the back burner. The code size will go back down in the second patch which removes the old implementation, although the number of source line reflects more comments and a test driver.
The infrastructure parts of this, such as the module name and Kconfig declarations, are something I haven't done before, and comments are appreciated.
Quoted 6 lines · Tejun Heo
Quoted 2 lines · George Spelvin
Sure; I'll prepare some patches. May I feed it through you, or is there a
lib/maintainer I need to go through?Please keep me cc'd but you'd probably also want to cc Linus, Andrew Morton and Ingo.
include/linux/glob.h | 10 +++ lib/Kconfig | 14 ++++ lib/Makefile | 2 + lib/glob.c | 225 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 251 insertions(+) create mode 100644 include/linux/glob.h create mode 100644 lib/glob.c
include/linux/glob.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _LINUX_GLOB_H +#define _LINUX_GLOB_H + +#include <linux/types.h> /* For bool */ +#include <linux/compiler.h> /* For __pure */ + +bool __pure glob_match (char const *pat,char const *str); + +#endif /* _LINUX_GLOB_H */ +
lib/Kconfig +14 -0
@@ -373,6 +373,20 @@ config CPU_RMAP config DQL bool +config GLOB + tristate +# (Prompt disabled to reduce kbuild clutter until someone needs it.) +# prompt "glob_match() function" + help + This option provides a glob_match function for performing simple + text pattern matching. It is primarily used by the ATA code + to blacklist particular drive models, but other device drivers + may need similar functionality. + + All in-kernel drivers that require this function automatically + select this option. Say N unless you are compiling an out-of + tree driver which tells you it depend on it. + # # Netlink attribute parsing support is select'ed if needed #
lib/Makefile +2 -0
@@ -133,6 +133,8 @@ obj-$(CONFIG_CORDIC) += cordic.o obj-$(CONFIG_DQL) += dynamic_queue_limits.o +obj-$(CONFIG_GLOB) += glob.o + obj-$(CONFIG_MPILIB) += mpi/ obj-$(CONFIG_SIGNATURE) += digsig.o
lib/glob.c new file +225 -0
225 lines not on this page · raw message
Signature · 1 line
1.9.2
PATCH 2/2 libata: Use glob_match from lib/glob.c
The function may be useful for other drivers, so export it. (Suggested by Tejun Heo.)
Note that I inverted the return value of glob_match; returning true on match seemed to make more sense.
--- drivers/ata/Kconfig | 1 + drivers/ata/libata-core.c | 72 ++--------------------------------------------- 2 files changed, 4 insertions(+), 69 deletions(-)
drivers/ata/Kconfig +1 -0
@@ -16,6 +16,7 @@ menuconfig ATA depends on BLOCK depends on !(M32R || M68K || S390) || BROKEN select SCSI + select GLOB ---help--- If you want to use a ATA hard disk, ATA tape drive, ATA CD-ROM or any other ATA device under Linux, say Y and make sure that you know
drivers/ata/libata-core.c +3 -69
92 lines not on this page · raw message
Signature · 1 line
1.9.2
Hello,
lib/Kconfig config CPU_RMAP · line 388
Quoted 13 lines · George Spelvin
lib/Kconfig +13
-0+config GLOB + tristate +# (Prompt disabled to reduce kbuild clutter until someone needs it.) +# prompt "glob_match() function" + help + This option provides a glob_match function for performing simple + text pattern matching. It is primarily used by the ATA code + to blacklist particular drive models, but other device drivers + may need similar functionality. + + All in-kernel drivers that require this function automatically + select this option. Say N unless you are compiling an out-of + tree driver which tells you it depend on it.
Just adding glob.o to lib-y should be enough. It will be excluded from linking if unused.
lib/glob.c line 7
Quoted 7 lines
lib/glob.c new file +7
-0+#ifdef UNITTEST +/* To do a basic sanity test, "cc -DUNITTEST glob.c" and run a.out. */ + +#include <stdbool.h> +#define __pure __attribute__((pure)) +#define NOP (x) +#define EXPORT_SYMBOL NOP/* Two stages to avoid checkpatch complaints */
These things tend to bitrot. Let's please keep testing harness out of tree.
lib/glob.c line 15
Quoted 7 lines
lib/glob.c new file +7
-0+#else + +#include <linux/module.h> +#include <linux/glob.h> + +MODULE_DESCRIPTION ("glob(7) matching" ); +MODULE_LICENSE ("Dual MIT/GPL" );
Do we make library routines separate modules usually?
...
lib/glob.c line 46
Quoted 2 lines
lib/glob.c new file +2
-0+bool __pure +glob_match (char const *pat,char const *str)
The whole thing fits in a single 80 column line, right?
bool __pure glob_match(char const *pat, char const *str)
lib/glob.c line 54
Quoted 8 lines
lib/glob.c new file +8
-0+{ +/* +* Backtrack to previous * on mismatch and retry starting one +* character later in the string. Because * matches all characters +* (no exception for /), it can be easily proved that there's +* never a need to backtrack multiple levels. +*/ +char const *back_pat =0 , *back_str = back_str;
Blank line here.
I haven't delved into the actual implementation. Looks sane on the first glance.
Quoted 24 lines
lib/glob.c new file +24
-0+#ifdef UNITTEST + +/* Test code */ +#include <stdio.h> +#include <stdlib.h> +struct glob_test { +char const *pat, *str; +bool expected; +}; + +static void +test (struct glob_test const *g) +{ +bool match =glob_match (g->pat, g->str); + +printf ("\"%s\" vs. \"%s\": %s %s\n" , g->pat, g->str, + match ?"match" :"mismatch" , + match == g->expected ?"OK" :"*** ERROR ***" ); +if (match != g->expected) +exit (1 ); +} + +static struct glob_test const tests[] = { + { "a", "a", true },
...
Quoted 5 lines
lib/glob.c new file +5
-0+ { "*ab*cd*", "abcabcabcabcefg", false } +}; + +int +main (void )
lib/glob.c line 225
Quoted 10 lines
lib/glob.c new file +10
-0+{ +size_t i; + +for (i =0 ; i <sizeof (tests)/sizeof (*tests); i++) +test (tests + i); + +return 0 ; +} + +#endif /* UNITTEST */
Again, I don't really think the userland testing code belongs here. If you wanna keep them, please make it in-kernel selftesting. We don't really wanna keep code which can't get built and tested in kernel tree proper.
Thanks.
Signature · 1 line
tejun
Ooh, one more nitpick.
Quoted 4 lines · George Spelvin
+/**
+ *glob_match- Shell-style pattern matching, like !fnmatch(pat, str, 0)
+ * @pat: Pattern to match. Metacharacters are ?, *, [ and \.
+ * (And, inside character classes, !, - and ].)
@ARG lines should be contained in a single line. Just "Pattern to match." should do. With detailed description in the body.
Thanks.
Signature · 1 line
tejun
Thanks a lot for the feedback!
Quoted 8 lines · George Spelvin
Quoted 4 lines
+/**
+ *glob_match- Shell-style pattern matching, like !fnmatch(pat, str, 0)
+ * @pat: Pattern to match. Metacharacters are ?, *, [ and \.
+ * (And, inside character classes, !, - and ].)@ARG lines should be contained in a single line. Just "Pattern to match." should do. With detailed description in the body.
Huh, Documentation/kernel-doc-nano-HOWTO.txt (lines 57-59, to be precise) implies otherwise pretty strongly. But I can certainly change it.
Quoted 2 lines
Just adding glob.o to lib-y should be enough. It will be excluded from linking if unused.
Will that work right if the caller is a module? What will it get linked into, the main kernel binary or the module?
A significant and very helpful simplification; I just want to be sure it works right.
Quoted 10 lines
lib/glob.c line 7
Quoted 7 lines
lib/glob.c new file +7
-0+#ifdef UNITTEST +/* To do a basic sanity test, "cc -DUNITTEST glob.c" and run a.out. */ + +#include <stdbool.h> +#define __pure __attribute__((pure)) +#define NOP (x) +#define EXPORT_SYMBOL NOP/* Two stages to avoid checkpatch complaints */ These things tend to bitrot. Let's please keep testing harness out of tree.
Damn, when separated it bitrots a lot faster. That's *is* my testing harness, and I wanted to keep it close so it has a chance on hell of being used by someone who updates it.
Especially given that the function's interface is quite rigidly defined, do you really think there will be a lot of rot?
Quoted 1 line
Do we make library routines separate modules usually?
A large number of files in lib/ are implemented that way (lib/crc-ccitt.c, just for one example), and that's what I copied. But if I just do the obj-y thing, all that goes away
Quoted 6 lines
lib/glob.c line 46
Quoted 2 lines
lib/glob.c new file +2
-0+bool __pure +glob_match (char const *pat,char const *str)The whole thing fits in a single 80 column line, right?
bool
__pureglob_match(char const *pat, char const *str)
Whoops, a residue of my personal code style. (I like to left-align function names in definitions so they're easy to search for with ^func.) But it's not kernel style. Will fix.
Quoted 10 lines
lib/glob.c line 54
Quoted 8 lines
lib/glob.c new file +8
-0+{ +/* +* Backtrack to previous * on mismatch and retry starting one +* character later in the string. Because * matches all characters +* (no exception for /), it can be easily proved that there's +* never a need to backtrack multiple levels. +*/ +char const *back_pat =0 , *back_str = back_str;Blank line here.
I had considered the "/*" start of the following block comment as visually enough separation between variable declarations and statements, but sure, I can add one.
Quoted 2 lines
I haven't delved into the actual implementation. Looks sane on the first glance.
That's the part I'm least worried about, actually.
Quoted 4 lines
Again, I don't really think the userland testing code belongs here. If you want to keep them, please make it in-kernel selftesting. We don't really want to keep code which can't get built and tested in kernel tree proper.
I'll see if I can figure out how to do that. Simple as it is, I hate to throw away regression tests.
Thank you very much.
Quoted 10 lines · George Spelvin
Thanks a lot for the feedback!
Quoted 8 lines · George Spelvin
Quoted 4 lines
+/**
+ *glob_match- Shell-style pattern matching, like !fnmatch(pat, str, 0)
+ * @pat: Pattern to match. Metacharacters are ?, *, [ and \.
+ * (And, inside character classes, !, - and ].)@ARG lines should be contained in a single line. Just "Pattern to match." should do. With detailed description in the body.
That's old/historical, not current.
Quoted 2 lines
Huh,
Documentation/kernel-doc-nano-HOWTO.txt(lines 57-59, to be precise) implies otherwise pretty strongly. But I can certainly change it.
Either way should be OK.
Quoted 5 lines
Quoted 2 lines
Just adding glob.o to lib-y should be enough. It will be excluded from linking if unused.
Will that work right if the caller is a module? What will it get linked into, the main kernel binary or the module?
and sometimes we have to use obj-y instead of lib-y.
Quoted 65 lines
A significant and very helpful simplification; I just want to be sure it works right.
Quoted 10 lines
lib/glob.c line 7
Quoted 7 lines
lib/glob.c new file +7
-0+#ifdef UNITTEST +/* To do a basic sanity test, "cc -DUNITTEST glob.c" and run a.out. */ + +#include <stdbool.h> +#define __pure __attribute__((pure)) +#define NOP (x) +#define EXPORT_SYMBOL NOP/* Two stages to avoid checkpatch complaints */ These things tend to bitrot. Let's please keep testing harness out of tree.
Damn, when separated it bitrots a lot faster. That's *is* my testing harness, and I wanted to keep it close so it has a chance on hell of being used by someone who updates it.
Especially given that the function's interface is quite rigidly defined, do you really think there will be a lot of rot?
Quoted 1 line
Do we make library routines separate modules usually?
A large number of files in
lib/are implemented that way (lib/crc-ccitt.c, just for one example), and that's what I copied. But if I just do the obj-y thing, all that goes awayQuoted 6 lines
lib/glob.c line 46
Quoted 2 lines
lib/glob.c new file +2
-0+bool __pure +glob_match (char const *pat,char const *str)The whole thing fits in a single 80 column line, right?
bool
__pureglob_match(char const *pat, char const *str)Whoops, a residue of my personal code style. (I like to left-align function names in definitions so they're easy to search for with ^func.) But it's not kernel style. Will fix.
Quoted 10 lines
lib/glob.c line 54
Quoted 8 lines
lib/glob.c new file +8
-0+{ +/* +* Backtrack to previous * on mismatch and retry starting one +* character later in the string. Because * matches all characters +* (no exception for /), it can be easily proved that there's +* never a need to backtrack multiple levels. +*/ +char const *back_pat =0 , *back_str = back_str;Blank line here.
I had considered the "/*" start of the following block comment as visually enough separation between variable declarations and statements, but sure, I can add one.
Quoted 2 lines
I haven't delved into the actual implementation. Looks sane on the first glance.
That's the part I'm least worried about, actually.
Quoted 4 lines
Again, I don't really think the userland testing code belongs here. If you want to keep them, please make it in-kernel selftesting. We don't really want to keep code which can't get built and tested in kernel tree proper.
I'll see if I can figure out how to do that. Simple as it is, I hate to throw away regression tests.
Signature · 1 line
~Randy
Quoted 41 lines · George Spelvin
This is a helper function from
drivers/ata/libata_core.c, where it is used to blacklist particular device models. It's being moved tolib/so other drivers may use it for the same purpose.This implementation in non-recursive, so is safe for the kernel stack.
Signed-off-by George Spelvin <[email protected]>---
Finally rescued this from the back burner. The code size will go back down in the second patch which removes the old implementation, although the number of source line reflects more comments and a test driver.The infrastructure parts of this, such as the module name and
Kconfigdeclarations, are something I haven't done before, and comments are appreciated.Quoted 6 lines · Tejun Heo
Quoted 2 lines · George Spelvin
Sure; I'll prepare some patches. May I feed it through you, or is there a
lib/maintainer I need to go through?Please keep me cc'd but you'd probably also want to cc Linus, Andrew Morton and Ingo.
include/linux/glob.h | 10 +++ lib/Kconfig | 14 ++++ lib/Makefile | 2 + lib/glob.c | 225 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 251 insertions(+) create mode 100644 include/linux/glob.h create mode 100644 lib/glob.clib/Kconfig +1
-0@@ -373,6 +373,20 @@ config CPU_RMAP config DQL bool +config GLOB
lib/Kconfig config CPU_RMAP · line 386
Quoted 10 lines
lib/Kconfig +10
-0+ tristate +# (Prompt disabled to reduce kbuild clutter until someone needs it.) +# prompt "glob_match() function" + help + This option provides a glob_match function for performing simple + text pattern matching. It is primarily used by the ATA code + to blacklist particular drive models, but other device drivers + may need similar functionality. + + All in-kernel drivers that require this function automatically
I would drop "automatically". It has to be coded.
lib/Kconfig config CPU_RMAP · line 388
Quoted 2 lines
lib/Kconfig +2
-0+ select this option. Say N unless you are compiling an out-of + tree driver which tells you it depend on it.
To support out-of-tree drivers, I'm pretty sure that you will need to use obj- instead of lib-. lib- drops unused code, like Tejun said.
Quoted 4 lines
lib/Kconfig +1
-0+ # # Netlink attribute parsing support is select'ed if needed #
Signature · 1 line
~Randy
Quoted 17 lines · Tejun Heo
lib/Kconfig config CPU_RMAP · line 388
Quoted 13 lines · George Spelvin
lib/Kconfig +13
-0+config GLOB + tristate +# (Prompt disabled to reduce kbuild clutter until someone needs it.) +# prompt "glob_match() function" + help + This option provides a glob_match function for performing simple + text pattern matching. It is primarily used by the ATA code + to blacklist particular drive models, but other device drivers + may need similar functionality. + + All in-kernel drivers that require this function automatically + select this option. Say N unless you are compiling an out-of + tree driver which tells you it depend on it.Just adding glob.o to lib-y should be enough. It will be excluded from linking if unused.
But, I just confirmed, it will also be excluded from linking if CONFIG_ATA=m. See for example commit b4d3ba3346f0 where some helpers had to be moved from lib-y to obj-y to fix module load errors. (Thanks to Randy Dunlap for this example.)
Quoted 9 lines
lib/glob.c line 15
Quoted 7 lines
lib/glob.c new file +7
-0+#else + +#include <linux/module.h> +#include <linux/glob.h> + +MODULE_DESCRIPTION ("glob(7) matching" ); +MODULE_LICENSE ("Dual MIT/GPL" );Do we make library routines separate modules usually?
There are basically three options I can see:
1) Make it non-configurable and always include the code in the kernel using oby-y, and just accept the wasted space if CONFIG_ATA=n
2) Make it a boolean option, so CONFIG_ATA=m will force CONFIG_GLOB=y and it will be included in the static kernel but unused until the module is loaded.
3) Make it a tristate option, which compiles into the kernel if CONFIG_ATA=y (the common case), and is its own module if CONFIG_ATA=m. An awful lot of the files in lib/ take this approach.
Do you have a preference? Option 3 is the current status.
(Revised patch will come when I have the self-test converted.)
Quoted 5 lines · Randy Dunlap
lib/Kconfig config CPU_RMAP · line 388
Quoted 2 lines
lib/Kconfig +2
-0+ select this option. Say N unless you are compiling an out-of + tree driver which tells you it depend on it.To support out-of-tree drivers, I'm pretty sure that you will need to use obj- instead of lib-. lib- drops unused code, like Tejun said.
I don't think we need to worry about out-of-tree drivers from the beginning.
Thanks.
Signature · 1 line
tejun
Andrew Morton
maintainerQuoted 9 lines · On Sat, 10 May 2014 08:21:38 -0400 Tejun Heo <[email protected]> wrote:
Quoted 9 lines
lib/glob.c new file +9
-0+int +main (void ) +{ +size_t i; + +for (i =0 ; i <sizeof (tests)/sizeof (*tests); i++) +test (tests + i); + +return 0 ;
Quoted 8 lines
lib/glob.c line 225
Quoted 3 lines
lib/glob.c new file +3
-0+} + +#endif /* UNITTEST */ Again, I don't really think the userland testing code belongs here. If you wanna keep them, please make it in-kernel selftesting. We don't really wanna keep code which can't get built and tested in kernel tree proper.
If the tests don't measurably increase boot times we could run them unconditionally at boot. Mark everything __init/__initdata and the costs are very low. lib/plist.c does this.
PATCH v2 1/3 Add lib/glob.c
In reply to Tejun HeoThis is a helper function from drivers/ata/libata_core.c, where it is used to blacklist particular device models. It's being moved to lib/ so other drivers may use it for the same purpose.
This implementation in non-recursive, so is safe for the kernel stack.
---
Sorry for the delay; while researching ways to organize the self-test code I found lots of other code to fix up.
Per previous discussion, support for out-of-tree users is currently disabled, although the machinery necessary to add it easily is still there.
If nothing else, it provides a good place to put the self-test code. (Which is now split out into a separate patch.)
I believe I've addressed all the comments made last time. Any more? (Acked-by: and Reviewed-by: particularly appreciated!)
include/linux/glob.h | 10 +++++ lib/Kconfig | 19 ++++++++ lib/Makefile | 2 + lib/glob.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 include/linux/glob.h create mode 100644 lib/glob.c
include/linux/glob.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _LINUX_GLOB_H +#define _LINUX_GLOB_H + +#include <linux/types.h> /* For bool */ +#include <linux/compiler.h> /* For __pure */ + +bool __pure glob_match (char const *pat,char const *str); + +#endif /* _LINUX_GLOB_H */ +
lib/Kconfig +19 -0
@@ -382,6 +382,25 @@ config CPU_RMAP config DQL bool +config GLOB + bool +# This actually supports modular compilation, but the module overhead +# is ridiculous for the amount of code involved. Until an out-of-tree +# driver asks for it, we'll just link it directly it into the kernel +# when required. Since we're ignoring out-of-tree users, there's also +# no need bother prompting for a manual decision: +# prompt "glob_match() function" + help + This option provides a glob_match function for performing + simple text pattern matching. It originated in the ATA code + to blacklist particular drive models, but other device drivers + may need similar functionality. + + All drivers in the Linux kernel tree that require this function + should automatically select this option. Say N unless you + are compiling an out-of tree driver which tells you that it + depends on this. + # # Netlink attribute parsing support is select'ed if needed #
lib/Makefile +2 -0
@@ -134,6 +134,8 @@ obj-$(CONFIG_CORDIC) += cordic.o obj-$(CONFIG_DQL) += dynamic_queue_limits.o +obj-$(CONFIG_GLOB) += glob.o + obj-$(CONFIG_MPILIB) += mpi/ obj-$(CONFIG_SIGNATURE) += digsig.o
lib/glob.c new file +123 -0
123 lines not on this page · raw message
Signature · 1 line
2.0.0
PATCH v2 2/3 lib: glob.c: Add CONFIG_GLOB_SELFTEST
This was useful during development, and is retained for future regression testing.
GCC appears to have no way to place string literals in a particular section; adding __initconst to a char pointer leaves the string itself in the default string section, where it will not be thrown away after module load.
Thus all string constants are kept in explicitly declared and named arrays. Sorry this makes printk a bit harder to read. At least the tests are more compact.
---
Persuading GCC to throw away *all* the self-test data after running it was surprisingly annoying.
The one thing I'm not really sure about is what to do if the self-test fails. For now, I make the module_init function fail too. Opinions?
lib/Kconfig | 14 ++++++ lib/glob.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+)
lib/Kconfig +14 -0
@@ -401,6 +401,20 @@ config GLOB are compiling an out-of tree driver which tells you that it depends on this. +config GLOB_SELFTEST + bool "glob self-test on init" + default n + depends on GLOB + help + This option enables a simple self-test of the glob_match + function on startup. It is primarily useful for people + working on the code to ensure they haven't introduced any + regressions. + + It only adds a little bit of code and slows kernel boot (or + module load) by a small amount, so you're welcome to play with + it, but you probably don't need it. + # # Netlink attribute parsing support is select'ed if needed #
lib/glob.c +164 -0
167 lines not on this page · raw message
Signature · 1 line
2.0.0
PATCH v2 3/3 libata: Use glob_match from lib/glob.c
In reply to George SpelvinThe function may be useful for other drivers, so export it. (Suggested by Tejun Heo.)
Note that I inverted the return value of glob_match; returning true on match seemed to make more sense.
---
This is unchanged vrom v1.
drivers/ata/Kconfig | 1 + drivers/ata/libata-core.c | 72 ++--------------------------------------------- 2 files changed, 4 insertions(+), 69 deletions(-)
drivers/ata/Kconfig +1 -0
@@ -16,6 +16,7 @@ menuconfig ATA depends on BLOCK depends on !(M32R || M68K || S390) || BROKEN select SCSI + select GLOB ---help--- If you want to use an ATA hard disk, ATA tape drive, ATA CD-ROM or any other ATA device under Linux, say Y and make sure that you know
drivers/ata/libata-core.c +3 -69
92 lines not on this page · raw message
Signature · 1 line
2.0.0
Andrew Morton
maintainerRe: [PATCH v2 2/3] lib: glob.c: Add CONFIG_GLOB_SELFTEST
In reply to George SpelvinQuoted 8 lines · On 6 Jun 2014 22:49:28 -0400 "George Spelvin" <[email protected]> wrote:
This was useful during development, and is retained for future regression testing.
GCC appears to have no way to place string literals in a particular section; adding
__initconstto a char pointer leaves the string itself in the default string section, where it will not be thrown away after module load.
Quoted 8 lines
Thus all string constants are kept in explicitly declared and named arrays. Sorry this makes printk a bit harder to read. At least the tests are more compact.
Signed-off-by George Spelvin <[email protected]>---
Persuading GCC to throw away *all* the self-test data after running it was surprisingly annoying.
Yeah. Props for making the attempt.
Quoted 2 lines
The one thing I'm not really sure about is what to do if the self-test fails. For now, I make the
module_initfunction fail too. Opinions?
The printk should suffice - someone will notice it eventually.
Using KERN_ERR to report a failure might help draw attention to it.
Re: [PATCH v2 2/3] lib: glob.c: Add CONFIG_GLOB_SELFTEST
Quoted 4 lines
Quoted 2 lines
Persuading GCC to throw away *all* the self-test data after running it was surprisingly annoying.
Yeah. Props for making the attempt.
*Whew*. I was worried I'd get upbraided for overoptimziation.
Quoted 6 lines
Quoted 2 lines
The one thing I'm not really sure about is what to do if the self-test fails. For now, I make the
module_initfunction fail too. Opinions?The printk should suffice - someone will notice it eventually.
Using
KERN_ERRto report a failure might help draw attention to it.
I'm not sure what you mean by "might"; I already *do* report it as KERN_ERR.
If you think failing the module load is a bad idea, feel free to modify the patch.