Skip to content

Commit 3a301d7

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: Clean up tb_fmt to not give faulty compile warning
gcc incorrectly states that the variable "fmt" is uninitialized when CC_OPITMIZE_FOR_SIZE is set. Instead of just blindly setting fmt to NULL, the code is cleaned up a little to be a bit easier for humans to follow, as well as gcc to know the variables are initialized. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 322a8b0 commit 3a301d7

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

‎kernel/trace/trace_printk.c‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,19 @@ void hold_module_trace_bprintk_format(const char **start, const char **end)
5959
continue;
6060
}
6161

62+
fmt = NULL;
6263
tb_fmt = kmalloc(sizeof(*tb_fmt), GFP_KERNEL);
63-
if (tb_fmt)
64+
if (tb_fmt) {
6465
fmt = kmalloc(strlen(*iter) + 1, GFP_KERNEL);
65-
if (tb_fmt && fmt) {
66-
list_add_tail(&tb_fmt->list, &trace_bprintk_fmt_list);
67-
strcpy(fmt, *iter);
68-
tb_fmt->fmt = fmt;
69-
*iter = tb_fmt->fmt;
70-
} else {
71-
kfree(tb_fmt);
72-
*iter = NULL;
66+
if (fmt) {
67+
list_add_tail(&tb_fmt->list, &trace_bprintk_fmt_list);
68+
strcpy(fmt, *iter);
69+
tb_fmt->fmt = fmt;
70+
} else
71+
kfree(tb_fmt);
7372
}
73+
*iter = fmt;
74+
7475
}
7576
mutex_unlock(&btrace_mutex);
7677
}

0 commit comments

Comments
 (0)