Skip to content

Commit

Permalink
tracing: Clean up tb_fmt to not give faulty compile warning
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Aug 11, 2011
1 parent 322a8b0 commit 3a301d7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions kernel/trace/trace_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,19 @@ void hold_module_trace_bprintk_format(const char **start, const char **end)
continue;
}

fmt = NULL;
tb_fmt = kmalloc(sizeof(*tb_fmt), GFP_KERNEL);
if (tb_fmt)
if (tb_fmt) {
fmt = kmalloc(strlen(*iter) + 1, GFP_KERNEL);
if (tb_fmt && fmt) {
list_add_tail(&tb_fmt->list, &trace_bprintk_fmt_list);
strcpy(fmt, *iter);
tb_fmt->fmt = fmt;
*iter = tb_fmt->fmt;
} else {
kfree(tb_fmt);
*iter = NULL;
if (fmt) {
list_add_tail(&tb_fmt->list, &trace_bprintk_fmt_list);
strcpy(fmt, *iter);
tb_fmt->fmt = fmt;
} else
kfree(tb_fmt);
}
*iter = fmt;

}
mutex_unlock(&btrace_mutex);
}
Expand Down

0 comments on commit 3a301d7

Please sign in to comment.