Commit 8a64f0cb authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] befs: debugging code cleanup

From: "Sergey S. Kostyliov" <rathamahata@php4.ru>

- Reduce stack usage.
- Kill useless duplication of error and warning messages when debug is on. Old
	behaviour was:
...
BeFS(hda1): 
parent 50f7b6fd
......@@ -29,22 +29,29 @@ void
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 @@ befs_warning(const struct super_block *sb, const char *fmt, ...)
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 @@ befs_debug(const struct super_block *sb, const char *fmt, ...)
#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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment