提交 93dcc6ea 编写于 作者: T Thomas Gleixner

ftrace: simplify hexprint

simplify hex to ascii conversion.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 bb065afb
...@@ -248,19 +248,18 @@ trace_seq_putmem(struct trace_seq *s, void *mem, size_t len) ...@@ -248,19 +248,18 @@ trace_seq_putmem(struct trace_seq *s, void *mem, size_t len)
} }
#define HEX_CHARS 17 #define HEX_CHARS 17
static const char hex2asc[] = "0123456789abcdef";
static int static int
trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len) trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len)
{ {
unsigned char hex[HEX_CHARS]; unsigned char hex[HEX_CHARS];
unsigned char *data; unsigned char *data = mem;
unsigned char byte; unsigned char byte;
int i, j; int i, j;
BUG_ON(len >= HEX_CHARS); BUG_ON(len >= HEX_CHARS);
data = mem;
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
for (i = 0, j = 0; i < len; i++) { for (i = 0, j = 0; i < len; i++) {
#else #else
...@@ -268,22 +267,10 @@ trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len) ...@@ -268,22 +267,10 @@ trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len)
#endif #endif
byte = data[i]; byte = data[i];
hex[j] = byte & 0x0f; hex[j++] = hex2asc[byte & 0x0f];
if (hex[j] >= 10) hex[j++] = hex2asc[byte >> 4];
hex[j] += 'a' - 10;
else
hex[j] += '0';
j++;
hex[j] = byte >> 4;
if (hex[j] >= 10)
hex[j] += 'a' - 10;
else
hex[j] += '0';
j++;
} }
hex[j] = ' '; hex[j++] = ' ';
j++;
return trace_seq_putmem(s, hex, j); return trace_seq_putmem(s, hex, j);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册