[PATCH] btrfs: Better handle btrfs_printk() defaults
From: Petr Mladek
Date: Tue Dec 13 2016 - 07:12:56 EST
The commit 262c5e86fec7cfd ("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.
Reported-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
---
fs/btrfs/super.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
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 @@ void __btrfs_handle_fs_error(struct btrfs_fs_info *fs_info, const char *function
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;
--
1.8.5.6