trace: rename trace_print_hex_seq arg and add kdoc
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 2 Feb 2017 16:09:54 +0000 (17:09 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 3 Feb 2017 20:50:18 +0000 (15:50 -0500)
Steven suggested to improve trace_print_hex_seq() a bit after commit
2acae0d5b0f7 ("trace: add variant without spacing in trace_print_hex_seq")
in two ways: i) by adding a kdoc comment for the helper function
itself and ii) by renaming 'spacing' argument into 'concatenate'
to better denote that we don't add spaces between each hex bytes.

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/trace_events.h
include/trace/trace_events.h
kernel/trace/trace_output.c

index cfa475a0e9ca31dca792bcc053f9514e688a2997..0f165507495c6e649c1942c982efa0d1be20befa 100644 (file)
@@ -34,7 +34,7 @@ const char *trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
 
 const char *trace_print_hex_seq(struct trace_seq *p,
                                const unsigned char *buf, int len,
-                               bool spacing);
+                               bool concatenate);
 
 const char *trace_print_array_seq(struct trace_seq *p,
                                   const void *buf, int count,
index 9f684629c3cf1e3e6c4117253ea2f11679b9e258..5c06f4af8323032f78ba447f5f66cd31bcb28282 100644 (file)
@@ -298,11 +298,11 @@ TRACE_MAKE_SYSTEM_STR();
 
 #undef __print_hex
 #define __print_hex(buf, buf_len)                                      \
-       trace_print_hex_seq(p, buf, buf_len, true)
+       trace_print_hex_seq(p, buf, buf_len, false)
 
 #undef __print_hex_str
 #define __print_hex_str(buf, buf_len)                                  \
-       trace_print_hex_seq(p, buf, buf_len, false)
+       trace_print_hex_seq(p, buf, buf_len, true)
 
 #undef __print_array
 #define __print_array(array, count, el_size)                           \
index 30a144b1b9eeb316a847a8d384ccba91b6e41bcf..aea6a1218c7db6bc7eb307a5ed4630d0b2542640 100644 (file)
@@ -162,15 +162,26 @@ trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
 }
 EXPORT_SYMBOL_GPL(trace_print_bitmask_seq);
 
+/**
+ * trace_print_hex_seq - print buffer as hex sequence
+ * @p: trace seq struct to write to
+ * @buf: The buffer to print
+ * @buf_len: Length of @buf in bytes
+ * @concatenate: Print @buf as single hex string or with spacing
+ *
+ * Prints the passed buffer as a hex sequence either as a whole,
+ * single hex string if @concatenate is true or with spacing after
+ * each byte in case @concatenate is false.
+ */
 const char *
 trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len,
-                   bool spacing)
+                   bool concatenate)
 {
        int i;
        const char *ret = trace_seq_buffer_ptr(p);
 
        for (i = 0; i < buf_len; i++)
-               trace_seq_printf(p, "%s%2.2x", !spacing || i == 0 ? "" : " ",
+               trace_seq_printf(p, "%s%2.2x", concatenate || i == 0 ? "" : " ",
                                 buf[i]);
        trace_seq_putc(p, 0);