Skip to content

Commit

Permalink
tracing: Don't print an extra separator of flags
Browse files Browse the repository at this point in the history
If __print_flags() is used after another __print_*() function, the
temp seq_file buffer will not be empty on entry, and the delimiter will
be printed even though there's just one field. We get something like:

	|S

instead of just:

	S

This is because the length of the temp seq buffer is used to determine
if the delimiter is printed or not. But this algorithm fails when
the seq buffer is not empty on entry, and the delimiter will be printed
because it thinks that a previous field was already printed.

Link: http://lkml.kernel.org/r/1329650167-480655-1-git-send-email-avagin@openvz.org

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Andrey Vagin authored and Steven Rostedt committed Feb 21, 2012
1 parent 09bda44 commit e404b32
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kernel/trace/trace_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ ftrace_print_flags_seq(struct trace_seq *p, const char *delim,
unsigned long mask;
const char *str;
const char *ret = p->buffer + p->len;
int i;
int i, first = 1;

for (i = 0; flag_array[i].name && flags; i++) {

Expand All @@ -310,8 +310,10 @@ ftrace_print_flags_seq(struct trace_seq *p, const char *delim,

str = flag_array[i].name;
flags &= ~mask;
if (p->len && delim)
if (!first && delim)
trace_seq_puts(p, delim);
else
first = 0;
trace_seq_puts(p, str);
}

Expand Down

0 comments on commit e404b32

Please sign in to comment.