usb.h: reduce syslog clutter
Subsystems (2)
PATCH 1/1 usb.h: reduce syslog clutter
The current versions of the err() / info() / warn() message macros in include/linux/usb.h insert __FILE__ at the beginning of the message. When those macros where introduced, back in 2.2 times, that expanded to the name of the source file, which was fine.
However, with the build process changes in 2.5, __FILE__ now expands to the complete path name of the source file within the kernel tree. Consequently, that part of the kernel message now takes up about half of an 80 character screen line.
The following patch modifies these macros so that, when used in a module, they'll insert the module name instead, which is significantly shorter and also tends to be more useful to users (as opposed to kernel developers) trying to make sense of a particular message.
It also adds a macro for the "notice" message level which was missing so far.
The triple checks for defined(CONFIG_MODULES), defined(THIS_MODULE) and THIS_MODULE are necessary to catch all possible combinations of
- kernel being built with or without module support
- source file #including linux/usb.h or not
- source file actually being built as a module or not
---
usb.h | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
include/linux/usb.h 2006-03-18 20:29:38.000000000 +0100 renamed from include/linux/usb.h 2006-02-27 06:09:35.000000000 +0100 +11 -3
@@ -1199,12 +1199,20 @@ #define dbg(format, arg...) do {} while (0) #endif +#if defined(CONFIG_MODULES) && defined(THIS_MODULE) +#define KMSG_LOCATION_PREFIX THIS_MODULE ? THIS_MODULE->name : __FILE__ +#else +#define KMSG_LOCATION_PREFIX __FILE__ +#endif + #define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ - __FILE__ , ## arg) + KMSG_LOCATION_PREFIX , ## arg) #define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \ - __FILE__ , ## arg) + KMSG_LOCATION_PREFIX , ## arg) #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \ - __FILE__ , ## arg) + KMSG_LOCATION_PREFIX , ## arg) +#define notice(format, arg...) printk(KERN_NOTICE "%s: " format "\n" , \ + KMSG_LOCATION_PREFIX , ## arg) #endif /* __KERNEL__ */
Signature · 4 lines
Tilman Schmidt E-Mail: [email protected] Bonn, Germany Help a man when he is in trouble and he will remember you when he is in trouble again.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
include/linux/usb.h 2006-03-18 20:29:38.000000000 +0100 line 1207
Quoted 6 lines · Tilman Schmidt
include/linux/usb.h 2006-03-18 20:29:38.000000000 +0100 renamed from include/linux/usb.h 2006-02-27 06:09:35.000000000 +0100 +6
-0+#if defined(CONFIG_MODULES) && defined(THIS_MODULE) +#define KMSG_LOCATION_PREFIX THIS_MODULE ? THIS_MODULE->name : __FILE__ +#else +#define KMSG_LOCATION_PREFIX __FILE__ +#endif +
Shouldn't this simply use KBUILD_MODNAME?
Arnd <><
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 9 lines · Arnd Bergmann
include/linux/usb.h 2006-03-18 20:29:38.000000000 +0100 line 1207
Quoted 6 lines · Tilman Schmidt
include/linux/usb.h 2006-03-18 20:29:38.000000000 +0100 renamed from include/linux/usb.h 2006-02-27 06:09:35.000000000 +0100 +6
-0+#if defined(CONFIG_MODULES) && defined(THIS_MODULE) +#define KMSG_LOCATION_PREFIX THIS_MODULE ? THIS_MODULE->name : __FILE__ +#else +#define KMSG_LOCATION_PREFIX __FILE__ +#endif +Shouldn't this simply use
KBUILD_MODNAME?
Thanks for the hint. I didn't know this expands to __FILE__ when not compiling for a module. That's perfect!
A small drawback is that, according to scripts/Makefile.lib:
"It's possible that one object gets potentially linked into more
than one module. In that case KBUILD_MODNAME will be set to foo_bar, where foo and bar are the name of the modules."
But I assume that's so rare it wouldn't warrant the more complicated solution I proposed.
Second take of patch follows.
Signature · 4 lines
Tilman Schmidt E-Mail: [email protected] Bonn, Germany Diese Nachricht besteht zu 100% aus wiederverwerteten Bits. Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 usb.h: reduce syslog clutter
In reply to Tilman SchmidtThe current versions of the err() / info() / warn() message macros in include/linux/usb.h insert __FILE__ at the beginning of the message. When those macros where introduced, back in 2.2 times, that expanded to the name of the source file, which was fine.
However, with the build process changes in 2.5, __FILE__ now expands to the complete path name of the source file within the kernel tree. Consequently, that part of the kernel message now takes up about half of an 80 character screen line.
The following patch modifies these macros so that, when used in a module, they'll insert the module name instead, which is significantly shorter and also tends to be more useful to users (as opposed to kernel developers) trying to make sense of a particular message.
It also adds a macro for the "notice" message level which was missing so far.
---
usb.h | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
include/linux/usb.h 2006-03-20 20:31:21.000000000 +0100 renamed from include/linux/usb.h 2006-02-27 06:09:35.000000000 +0100 +8 -6
@@ -1199,12 +1199,14 @@ #define dbg(format, arg...) do {} while (0) #endif -#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ - __FILE__ , ## arg) -#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \ - __FILE__ , ## arg) -#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \ - __FILE__ , ## arg) +#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ + format "\n" , ## arg) +#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \ + format "\n" , ## arg) +#define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \ + format "\n" , ## arg) +#define notice(format, arg...) printk(KERN_NOTICE KBUILD_MODNAME ": " \ + format "\n" , ## arg) #endif /* __KERNEL__ */
Signature · 2 lines
Tilman Schmidt E-Mail: [email protected] Bonn, Germany
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors