[PATCH] befs (5/5): debugging code cleanup
From: Sergey S. Kostyliov
Date: Thu May 13 2004 - 13:35:29 EST
- Reduce stack usage.
- Kill useless duplication of error and warning messages when debug is on. Old
behaviour was:
...
BeFS(hda1): ---> befs_fill_super()
BeFS(hda1): No write support. Marking filesystem read-only
BeFS(hda1): No write support. Marking filesystem read-only
...
===== fs/befs/debug.c 1.2 vs edited =====
--- 1.2/fs/befs/debug.c Thu Mar 20 21:47:37 2003
+++ edited/fs/befs/debug.c Thu May 13 20:58:26 2004
@@ -29,22 +29,29 @@
befs_error(const struct super_block *sb, const char *fmt, ...)
{
va_list args;
- char err_buf[ERRBUFSIZE];
-
+ char *err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL);
+ if (err_buf == NULL) {
+ printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
+ return;
+ }
+
va_start(args, fmt);
vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
va_end(args);
printk(KERN_ERR "BeFS(%s): %s\n", sb->s_id, err_buf);
-
- befs_debug(sb, err_buf);
+ kfree(err_buf);
}
void
befs_warning(const struct super_block *sb, const char *fmt, ...)
{
va_list args;
- char err_buf[ERRBUFSIZE];
+ char *err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL);
+ if (err_buf == NULL) {
+ printk(KERN_ERR "could not allocate %d bytes\n", ERRBUFSIZE);
+ return;
+ }
va_start(args, fmt);
vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
@@ -52,7 +59,7 @@
printk(KERN_WARNING "BeFS(%s): %s\n", sb->s_id, err_buf);
- befs_debug(sb, err_buf);
+ kfree(err_buf);
}
void
@@ -61,15 +68,25 @@
#ifdef CONFIG_BEFS_DEBUG
va_list args;
- char err_buf[ERRBUFSIZE];
+ char *err_buf = NULL;
if (BEFS_SB(sb)->mount_opts.debug) {
+ err_buf = (char *) kmalloc(ERRBUFSIZE, GFP_KERNEL);
+ if (err_buf == NULL) {
+ printk(KERN_ERR "could not allocate %d bytes\n",
+ ERRBUFSIZE);
+ return;
+ }
+
va_start(args, fmt);
vsnprintf(err_buf, ERRBUFSIZE, fmt, args);
va_end(args);
printk(KERN_DEBUG "BeFS(%s): %s\n", sb->s_id, err_buf);
+
+ kfree(err_buf);
}
+
#endif //CONFIG_BEFS_DEBUG
}
--
Best regards,
Sergey S. Kostyliov <rathamahata@xxxxxxx>
Public PGP key: http://sysadminday.org.ru/rathamahata.asc
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/