lkml.org 
[lkml]   [2013]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 5/4] tracing: Simplify the ftrace_event_field iteration in f_next/f_show
On 07/17, Oleg Nesterov wrote:
>
> f_next() looks overcomplicated, and it is not strictly correct
> even if this doesn't matter.

Honestly, I do not know what the changelog can say to explain
this patch except "make the code simpler/cleaner".

To simplify the review, please see f_next/f_start with this patch
applied below. f_show() does field = list_entry(v, ...).

Probably makes sense anyway, I even tried to test it. So I would
not mind if you apply it as a separate cleanup ;)

Oleg.

static void *f_next(struct seq_file *m, void *v, loff_t *pos)
{
struct ftrace_event_call *call = m->private;
struct list_head *common_head = &ftrace_common_fields;
struct list_head *head = trace_get_fields(call);
struct list_head *node = v;

(*pos)++;

switch ((unsigned long)v) {
case FORMAT_HEADER:
node = common_head;
break;

case FORMAT_FIELD_SEPERATOR:
node = head;
break;

case FORMAT_PRINTFMT:
/* all done */
return NULL;
}

node = node->prev;
if (node == common_head)
return (void *)FORMAT_FIELD_SEPERATOR;
else if (node == head)
return (void *)FORMAT_PRINTFMT;
else
return node;
}

static void *f_start(struct seq_file *m, loff_t *pos)
{
void *p = (void *)FORMAT_HEADER;
loff_t l = 0;

while (p && l < *pos)
p = f_next(m, p, &l);

return p;
}



\
 
 \ /
  Last update: 2013-07-17 22:21    [W:0.072 / U:5.932 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site