From: Petr Mladek Date: Wed, 14 Dec 2016 23:04:01 +0000 (-0800) Subject: btrfs: better handle btrfs_printk() defaults X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=40f7828b36e3b9dd2fdc34d065e342cddf8d7bef;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git btrfs: better handle btrfs_printk() defaults Commit 262c5e86fec7 ("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.cz Signed-off-by: Petr Mladek Reported-by: Geert Uytterhoeven Reviewed-by: Geert Uytterhoeven Acked-by: David Sterba Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 180f910339f4..3b713b6fcc26 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -202,12 +202,12 @@ static struct ratelimit_state printk_limits[] = { void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) { 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; va_list args; - const char *type = NULL; int kern_level; - struct ratelimit_state *ratelimit; + const char *type = logtypes[4]; + struct ratelimit_state *ratelimit = &printk_limits[4]; va_start(args, fmt); @@ -223,12 +223,6 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) fmt += size; } - if (!type) { - *lvl = '\0'; - type = logtypes[4]; - ratelimit = &printk_limits[4]; - } - vaf.fmt = fmt; vaf.va = &args;