diff options
author | Joel Kitching <kitching@google.com> | 2018-11-28 17:34:22 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-12-03 12:43:22 -0800 |
commit | b343c963b38b03df97a1bc57f201e26640c89e47 (patch) | |
tree | d0acdb86d8621e887e4104473eed40e02e74ea0b /extra | |
parent | 8a5814e1a8890c988a5315314597628fa0882a3c (diff) | |
download | chrome-ec-b343c963b38b03df97a1bc57f201e26640c89e47.tar.gz |
gsctool: verbose flag should print debug messages
Currently the verbose flag is stored in `verbose_mode` but
never used. Print conditionally on this flag within a new
`debug` function.
BUG=None
TEST=try running various commands with --verbose
check for verbose output
BRANCH=master
Change-Id: Iadaf1a91ea1b02b0638e6364077c2c148f26e03c
Reviewed-on: https://chromium-review.googlesource.com/1351926
Commit-Ready: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'extra')
-rw-r--r-- | extra/usb_updater/gsctool.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index 5193df039e..358e10a6de 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -36,12 +36,6 @@ #include "usb_descriptor.h" #include "verify_ro.h" -#ifdef DEBUG -#define debug printf -#else -#define debug(fmt, args...) -#endif - /* * This file contains the source code of a Linux application used to update * CR50 device firmware. @@ -245,6 +239,17 @@ static const struct option long_opts[] = { }; +/* Helper to print debug messages when verbose flag is specified. */ +static void debug(const char *fmt, ...) +{ + va_list args; + + if (verbose_mode) { + va_start(args, fmt); + vprintf(fmt, args); + va_end(args); + } +} /* Helpers to convert between binary and hex ascii and back. */ static char to_hexascii(uint8_t c) @@ -471,7 +476,6 @@ static int tpm_send_pkt(struct transfer_descriptor *td, unsigned int digest, break; } -#ifdef DEBUG debug("Read %d bytes from TPM\n", len); if (len > 0) { int i; @@ -480,7 +484,6 @@ static int tpm_send_pkt(struct transfer_descriptor *td, unsigned int digest, debug("%2.2x ", outbuf[i]); debug("\n"); } -#endif len = len - response_offset; if (len < 0) { fprintf(stderr, "Problems reading from TPM, got %d bytes\n", |