Skip to content

Commit 352d94d

Browse files
Alexey DobriyanLinus Torvalds
authored andcommitted
[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: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 4a6e617 commit 352d94d

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

‎fs/hpfs/hpfs_fn.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
317317

318318
/* super.c */
319319

320-
void hpfs_error(struct super_block *, char *, ...);
320+
void hpfs_error(struct super_block *, const char *, ...)
321+
__attribute__((format (printf, 2, 3)));
321322
int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *);
322323
unsigned hpfs_count_one_bitmap(struct super_block *, secno);
323324

‎fs/hpfs/super.c‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,17 @@ static void unmark_dirty(struct super_block *s)
4646
}
4747

4848
/* Filesystem error... */
49+
static char err_buf[1024];
4950

50-
#define ERR_BUF_SIZE 1024
51-
52-
void hpfs_error(struct super_block *s, char *m,...)
51+
void hpfs_error(struct super_block *s, const char *fmt, ...)
5352
{
54-
char *buf;
55-
va_list l;
56-
va_start(l, m);
57-
if (!(buf = kmalloc(ERR_BUF_SIZE, GFP_KERNEL)))
58-
printk("HPFS: No memory for error message '%s'\n",m);
59-
else if (vsprintf(buf, m, l) >= ERR_BUF_SIZE)
60-
printk("HPFS: Grrrr... Kernel memory corrupted ... going on, but it'll crash very soon :-(\n");
61-
printk("HPFS: filesystem error: ");
62-
if (buf) printk("%s", buf);
63-
else printk("%s\n",m);
53+
va_list args;
54+
55+
va_start(args, fmt);
56+
vsnprintf(err_buf, sizeof(err_buf), fmt, args);
57+
va_end(args);
58+
59+
printk("HPFS: filesystem error: %s", err_buf);
6460
if (!hpfs_sb(s)->sb_was_error) {
6561
if (hpfs_sb(s)->sb_err == 2) {
6662
printk("; crashing the system because you wanted it\n");
@@ -76,7 +72,6 @@ void hpfs_error(struct super_block *s, char *m,...)
7672
} else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n");
7773
else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n");
7874
} else printk("\n");
79-
kfree(buf);
8075
hpfs_sb(s)->sb_was_error = 1;
8176
}
8277

0 commit comments

Comments
 (0)