Skip to content

Commit

Permalink
tracing: Add missing spaces in trace_print_hex_seq()
Browse files Browse the repository at this point in the history
If the buffer length is larger than 16 and concatenate is set to false,
there would be missing spaces every 16 bytes.
Example:
  Before: c5 11 10 50 05 4d 31 40 00 40 00 40 00 4d 31 4000 40 00
  After:  c5 11 10 50 05 4d 31 40 00 40 00 40 00 4d 31 40 00 40 00

Link: https://lore.kernel.org/linux-trace-kernel/20230426032257.3157247-1-lyenting@google.com

Signed-off-by: Ken Lin <lyenting@google.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
  • Loading branch information
lyenting authored and rostedt committed Apr 26, 2023
1 parent 7c339fb commit adace44
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/trace/trace_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,11 @@ trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len,
const char *ret = trace_seq_buffer_ptr(p);
const char *fmt = concatenate ? "%*phN" : "%*ph";

for (i = 0; i < buf_len; i += 16)
for (i = 0; i < buf_len; i += 16) {
if (!concatenate && i != 0)
trace_seq_putc(p, ' ');
trace_seq_printf(p, fmt, min(buf_len - i, 16), &buf[i]);
}
trace_seq_putc(p, 0);

return ret;
Expand Down

0 comments on commit adace44

Please sign in to comment.