diff mbox series

[1/5] backends/tpm: Remove newline character in trace event

Message ID 20240606103943.79116-2-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series trace: Remove and forbid newline characters in event format | expand

Commit Message

Philippe Mathieu-Daudé June 6, 2024, 10:39 a.m. UTC
Split the 'tpm_util_show_buffer' event in two to avoid
using a newline character.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 backends/tpm/tpm_util.c   | 5 +++--
 backends/tpm/trace-events | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

Comments

Daniel P. Berrangé June 6, 2024, 11:20 a.m. UTC | #1
On Thu, Jun 06, 2024 at 12:39:39PM +0200, Philippe Mathieu-Daudé wrote:
> Split the 'tpm_util_show_buffer' event in two to avoid
> using a newline character.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  backends/tpm/tpm_util.c   | 5 +++--
>  backends/tpm/trace-events | 3 ++-
>  2 files changed, 5 insertions(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


With regards,
Daniel
Stefan Berger June 7, 2024, 3:15 p.m. UTC | #2
On 6/6/24 06:39, Philippe Mathieu-Daudé wrote:
> Split the 'tpm_util_show_buffer' event in two to avoid
> using a newline character.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   backends/tpm/tpm_util.c   | 5 +++--
>   backends/tpm/trace-events | 3 ++-
>   2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
> index 1856589c3b..cf138551df 100644
> --- a/backends/tpm/tpm_util.c
> +++ b/backends/tpm/tpm_util.c
> @@ -339,10 +339,11 @@ void tpm_util_show_buffer(const unsigned char *buffer,
>       size_t len, i;
>       char *line_buffer, *p;
> 
> -    if (!trace_event_get_state_backends(TRACE_TPM_UTIL_SHOW_BUFFER)) {
> +    if (!trace_event_get_state_backends(TRACE_TPM_UTIL_SHOW_BUFFER_CONTENT)) {
>           return;
>       }
>       len = MIN(tpm_cmd_get_size(buffer), buffer_size);
> +    trace_tpm_util_show_buffer_header(string, len);
> 
>       /*
>        * allocate enough room for 3 chars per buffer entry plus a
> @@ -356,7 +357,7 @@ void tpm_util_show_buffer(const unsigned char *buffer,
>           }
>           p += sprintf(p, "%.2X ", buffer[i]);
>       }
> -    trace_tpm_util_show_buffer(string, len, line_buffer);
> +    trace_tpm_util_show_buffer_content(line_buffer);
> 
>       g_free(line_buffer);
>   }
> diff --git a/backends/tpm/trace-events b/backends/tpm/trace-events
> index 1ecef42a07..cb5cfa6510 100644
> --- a/backends/tpm/trace-events
> +++ b/backends/tpm/trace-events
> @@ -10,7 +10,8 @@ tpm_util_get_buffer_size_len(uint32_t len, size_t expected) "tpm_resp->len = %u,
>   tpm_util_get_buffer_size_hdr_len2(uint32_t len, size_t expected) "tpm2_resp->hdr.len = %u, expected = %zu"
>   tpm_util_get_buffer_size_len2(uint32_t len, size_t expected) "tpm2_resp->len = %u, expected = %zu"
>   tpm_util_get_buffer_size(size_t len) "buffersize of device: %zu"
> -tpm_util_show_buffer(const char *direction, size_t len, const char *buf) "direction: %s len: %zu\n%s"
> +tpm_util_show_buffer_header(const char *direction, size_t len) "direction: %s len: %zu"
> +tpm_util_show_buffer_content(const char *buf) "%s"
> 
>   # tpm_emulator.c
>   tpm_emulator_set_locality(uint8_t locty) "setting locality to %d"


Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
diff mbox series

Patch

diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c
index 1856589c3b..cf138551df 100644
--- a/backends/tpm/tpm_util.c
+++ b/backends/tpm/tpm_util.c
@@ -339,10 +339,11 @@  void tpm_util_show_buffer(const unsigned char *buffer,
     size_t len, i;
     char *line_buffer, *p;
 
-    if (!trace_event_get_state_backends(TRACE_TPM_UTIL_SHOW_BUFFER)) {
+    if (!trace_event_get_state_backends(TRACE_TPM_UTIL_SHOW_BUFFER_CONTENT)) {
         return;
     }
     len = MIN(tpm_cmd_get_size(buffer), buffer_size);
+    trace_tpm_util_show_buffer_header(string, len);
 
     /*
      * allocate enough room for 3 chars per buffer entry plus a
@@ -356,7 +357,7 @@  void tpm_util_show_buffer(const unsigned char *buffer,
         }
         p += sprintf(p, "%.2X ", buffer[i]);
     }
-    trace_tpm_util_show_buffer(string, len, line_buffer);
+    trace_tpm_util_show_buffer_content(line_buffer);
 
     g_free(line_buffer);
 }
diff --git a/backends/tpm/trace-events b/backends/tpm/trace-events
index 1ecef42a07..cb5cfa6510 100644
--- a/backends/tpm/trace-events
+++ b/backends/tpm/trace-events
@@ -10,7 +10,8 @@  tpm_util_get_buffer_size_len(uint32_t len, size_t expected) "tpm_resp->len = %u,
 tpm_util_get_buffer_size_hdr_len2(uint32_t len, size_t expected) "tpm2_resp->hdr.len = %u, expected = %zu"
 tpm_util_get_buffer_size_len2(uint32_t len, size_t expected) "tpm2_resp->len = %u, expected = %zu"
 tpm_util_get_buffer_size(size_t len) "buffersize of device: %zu"
-tpm_util_show_buffer(const char *direction, size_t len, const char *buf) "direction: %s len: %zu\n%s"
+tpm_util_show_buffer_header(const char *direction, size_t len) "direction: %s len: %zu"
+tpm_util_show_buffer_content(const char *buf) "%s"
 
 # tpm_emulator.c
 tpm_emulator_set_locality(uint8_t locty) "setting locality to %d"