Commit 40f7828b authored by Petr Mladek's avatar Petr Mladek Committed by Linus Torvalds

btrfs: better handle btrfs_printk() defaults

Commit 262c5e86 ("printk/btrfs: handle more message headers")
triggers:

    warning: `ratelimit' may be used uninitialized in this function

with gcc (4.1.2) and probably many other versions.  The code actually is
correct but a bit twisted.  Let's make it more straightforward and set
the default values at the beginning.

Link: http://lkml.kernel.org/r/20161213135246.GQ3506@pathway.suse.czSigned-off-by: default avatarPetr Mladek <pmladek@suse.com>
Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 775a2e29
...@@ -202,12 +202,12 @@ static struct ratelimit_state printk_limits[] = { ...@@ -202,12 +202,12 @@ static struct ratelimit_state printk_limits[] = {
void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
{ {
struct super_block *sb = fs_info->sb; struct super_block *sb = fs_info->sb;
char lvl[PRINTK_MAX_SINGLE_HEADER_LEN + 1]; char lvl[PRINTK_MAX_SINGLE_HEADER_LEN + 1] = "\0";
struct va_format vaf; struct va_format vaf;
va_list args; va_list args;
const char *type = NULL;
int kern_level; int kern_level;
struct ratelimit_state *ratelimit; const char *type = logtypes[4];
struct ratelimit_state *ratelimit = &printk_limits[4];
va_start(args, fmt); va_start(args, fmt);
...@@ -223,12 +223,6 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) ...@@ -223,12 +223,6 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
fmt += size; fmt += size;
} }
if (!type) {
*lvl = '\0';
type = logtypes[4];
ratelimit = &printk_limits[4];
}
vaf.fmt = fmt; vaf.fmt = fmt;
vaf.va = &args; vaf.va = &args;
......
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