tracing: Clean up tb_fmt to not give faulty compile warning
authorSteven Rostedt <srostedt@redhat.com>
Tue, 9 Aug 2011 01:39:39 +0000 (21:39 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Thu, 11 Aug 2011 00:36:32 +0000 (20:36 -0400)
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>
kernel/trace/trace_printk.c

index 1f06468a10d7a65ad8c0bffa8e13c0eaf44a8ad4..6fd4ffd042f9071fa158400c147de5a55914975d 100644 (file)
@@ -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);
 }