]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
tracing: Simplify the iteration logic in f_start/f_next
authorOleg Nesterov <oleg@redhat.com>
Thu, 18 Jul 2013 18:47:10 +0000 (20:47 +0200)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 19 Jul 2013 01:31:32 +0000 (21:31 -0400)
commit7710b639953b791610f0022a7d52d9801c93b969
treead1e4822ad3b1b067ee2806142613caec0ed1e60
parent8f768993394a8c0d3801033c11fd86ce8c88dcac
tracing: Simplify the iteration logic in f_start/f_next

f_next() looks overcomplicated, and it is not strictly correct
even if this doesn't matter.

Say, FORMAT_FIELD_SEPERATOR should not return NULL (means EOF)
if trace_get_fields() returns an empty list, we should simply
advance to FORMAT_PRINTFMT as we do when we find the end of list.

1. Change f_next() to return "struct list_head *" rather than
   "ftrace_event_field *", and change f_show() to do list_entry().

   This simplifies the code a bit, only f_show() needs to know
   about ftrace_event_field, and f_next() can play with ->prev
   directly

2. Change f_next() to not play with ->prev / return inside the
   switch() statement. It can simply set node = head/common_head,
   the prev-or-advance-to-the-next-magic below does all work.

While at it. f_start() looks overcomplicated too. I don't think
*pos == 0 makes sense as a separate case, just change this code
to do "while" instead of "do/while".

The patch also moves f_start() down, close to f_stop(). This is
purely cosmetic, just to make the locking added by the next patch
more clear/visible.

Link: http://lkml.kernel.org/r/20130718184710.GA4783@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_events.c