summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEvan Green <evgreen@chromium.org>2019-07-19 16:20:45 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-05 00:47:36 +0000
commit0128582fe62b51a74a4c6c5a91e9c5118e70e376 (patch)
tree7d8d96c756da853b87d36497ba649b1fc8dad398 /include
parenta41fea6b7df1c83072140c0da9e07f09a8b032e4 (diff)
downloadchrome-ec-0128582fe62b51a74a4c6c5a91e9c5118e70e376.tar.gz
printf: Convert %T to %pT
In order to be more compliant to standards, and ultimately turn on compile-time printf format validation, switch the non-standard %T into %pT, which takes a pointer to a 64-bit timestamp as an argument. For convenience, define PRINTF_TIMESTAMP_NOW, which will use the current time as the timestamp value, rather than forcing everyone to pass a pointer to get_time().val. For a couple of instances, simply use CPRINTS instead. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Cq-Depend:chrome-internal:1473305 Change-Id: I83e45b55a95ea27256dc147544ae3f7e39acc5dd Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704216 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/console.h4
-rw-r--r--include/printf.h5
2 files changed, 6 insertions, 3 deletions
diff --git a/include/console.h b/include/console.h
index e456ded7a6..73e9d9094c 100644
--- a/include/console.h
+++ b/include/console.h
@@ -10,6 +10,8 @@
#include "common.h"
+#define PRINTF_TIMESTAMP_NOW NULL
+
/* Console command; used by DECLARE_CONSOLE_COMMAND macro. */
struct console_command {
/* Command name. Case-insensitive. */
@@ -86,7 +88,7 @@ int cprintf(enum console_channel channel, const char *format, ...);
/**
* Print formatted output with timestamp. This is like:
- * cprintf(channel, "[%T " + format + "]\n", ...)
+ * cprintf(channel, "[%pT " + format + "]\n", PRINTF_TIMESTAMP_NOW, ...)
*
* @param channel Output channel
* @param format Format string; see printf.h for valid formatting codes
diff --git a/include/printf.h b/include/printf.h
index 6162e98bd2..c55c8f7d2b 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -52,8 +52,9 @@
* - 'b' - unsigned integer, print as binary
*
* Special format codes:
- * - "%T" - current time in seconds - interpreted as "%.6T" for precision.
- * This does NOT use up any arguments.
+ * - "%pT" - current time in seconds - interpreted as "%.6T" for precision.
+ * Supply PRINTF_TIMESTAMP_NOW to use the current time, or supply a
+ * pointer to a 64-bit timestamp to print.
*/
#ifndef HIDE_EC_STDLIB