Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86397dc3 authored by Li Zefan's avatar Li Zefan Committed by Steven Rostedt
Browse files

tracing: Clean up seqfile code for format file



Remove the nasty hack that marks a pointer's LSB to distinguish common
fields from event fields. Replace it with a more sane approach.

Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4C6A23C2.9020606@cn.fujitsu.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent 351af072
Loading
Loading
Loading
Loading
+18 −37
Original line number Original line Diff line number Diff line
@@ -600,21 +600,29 @@ system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,


enum {
enum {
	FORMAT_HEADER		= 1,
	FORMAT_HEADER		= 1,
	FORMAT_PRINTFMT		= 2,
	FORMAT_FIELD_SEPERATOR	= 2,
	FORMAT_PRINTFMT		= 3,
};
};


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


	(*pos)++;
	(*pos)++;


	switch ((unsigned long)v) {
	switch ((unsigned long)v) {
	case FORMAT_HEADER:
	case FORMAT_HEADER:
		head = &ftrace_common_fields;
		if (unlikely(list_empty(common_head)))
			return NULL;

		field = list_entry(common_head->prev,
				   struct ftrace_event_field, link);
		return field;


	case FORMAT_FIELD_SEPERATOR:
		if (unlikely(list_empty(head)))
		if (unlikely(list_empty(head)))
			return NULL;
			return NULL;


@@ -626,31 +634,10 @@ static void *f_next(struct seq_file *m, void *v, loff_t *pos)
		return NULL;
		return NULL;
	}
	}


	head = trace_get_fields(call);

	/*
	 * To separate common fields from event fields, the
	 * LSB is set on the first event field. Clear it in case.
	 */
	v = (void *)((unsigned long)v & ~1L);

	field = v;
	field = v;
	/*
	if (field->link.prev == common_head)
	 * If this is a common field, and at the end of the list, then
		return (void *)FORMAT_FIELD_SEPERATOR;
	 * continue with main list.
	else if (field->link.prev == head)
	 */
	if (field->link.prev == &ftrace_common_fields) {
		if (unlikely(list_empty(head)))
			return NULL;
		field = list_entry(head->prev, struct ftrace_event_field, link);
		/* Set the LSB to notify f_show to print an extra newline */
		field = (struct ftrace_event_field *)
			((unsigned long)field | 1);
		return field;
	}

	/* If we are done tell f_show to print the format */
	if (field->link.prev == head)
		return (void *)FORMAT_PRINTFMT;
		return (void *)FORMAT_PRINTFMT;


	field = list_entry(field->link.prev, struct ftrace_event_field, link);
	field = list_entry(field->link.prev, struct ftrace_event_field, link);
@@ -688,22 +675,16 @@ static int f_show(struct seq_file *m, void *v)
		seq_printf(m, "format:\n");
		seq_printf(m, "format:\n");
		return 0;
		return 0;


	case FORMAT_FIELD_SEPERATOR:
		seq_putc(m, '\n');
		return 0;

	case FORMAT_PRINTFMT:
	case FORMAT_PRINTFMT:
		seq_printf(m, "\nprint fmt: %s\n",
		seq_printf(m, "\nprint fmt: %s\n",
			   call->print_fmt);
			   call->print_fmt);
		return 0;
		return 0;
	}
	}


	/*
	 * To separate common fields from event fields, the
	 * LSB is set on the first event field. Clear it and
	 * print a newline if it is set.
	 */
	if ((unsigned long)v & 1) {
		seq_putc(m, '\n');
		v = (void *)((unsigned long)v & ~1L);
	}

	field = v;
	field = v;


	/*
	/*