Commit 352d94d0 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

[PATCH] hpfs: bring hpfs_error() into shape

 - switch to error message buffer in .bss
 - missing va_end() (htf it worked before?)
 - use vsnprintf()
 - rename variables to understandable "fmt", "args".
 - "const char *fmt", yes.
 - add __attribute__((format ...

Still, put that coffee down before reading more.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4a6e617a
...@@ -317,7 +317,8 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb) ...@@ -317,7 +317,8 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
/* super.c */ /* super.c */
void hpfs_error(struct super_block *, char *, ...); void hpfs_error(struct super_block *, const char *, ...)
__attribute__((format (printf, 2, 3)));
int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *); int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *);
unsigned hpfs_count_one_bitmap(struct super_block *, secno); unsigned hpfs_count_one_bitmap(struct super_block *, secno);
......
...@@ -46,21 +46,17 @@ static void unmark_dirty(struct super_block *s) ...@@ -46,21 +46,17 @@ static void unmark_dirty(struct super_block *s)
} }
/* Filesystem error... */ /* Filesystem error... */
static char err_buf[1024];
#define ERR_BUF_SIZE 1024 void hpfs_error(struct super_block *s, const char *fmt, ...)
void hpfs_error(struct super_block *s, char *m,...)
{ {
char *buf; va_list args;
va_list l;
va_start(l, m); va_start(args, fmt);
if (!(buf = kmalloc(ERR_BUF_SIZE, GFP_KERNEL))) vsnprintf(err_buf, sizeof(err_buf), fmt, args);
printk("HPFS: No memory for error message '%s'\n",m); va_end(args);
else if (vsprintf(buf, m, l) >= ERR_BUF_SIZE)
printk("HPFS: Grrrr... Kernel memory corrupted ... going on, but it'll crash very soon :-(\n"); printk("HPFS: filesystem error: %s", err_buf);
printk("HPFS: filesystem error: ");
if (buf) printk("%s", buf);
else printk("%s\n",m);
if (!hpfs_sb(s)->sb_was_error) { if (!hpfs_sb(s)->sb_was_error) {
if (hpfs_sb(s)->sb_err == 2) { if (hpfs_sb(s)->sb_err == 2) {
printk("; crashing the system because you wanted it\n"); printk("; crashing the system because you wanted it\n");
...@@ -76,7 +72,6 @@ void hpfs_error(struct super_block *s, char *m,...) ...@@ -76,7 +72,6 @@ void hpfs_error(struct super_block *s, char *m,...)
} else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n");
else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n"); else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n");
} else printk("\n"); } else printk("\n");
kfree(buf);
hpfs_sb(s)->sb_was_error = 1; hpfs_sb(s)->sb_was_error = 1;
} }
......
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