From e2e0125921490c1b148acbb7c7a19acf6bcad080 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 28 Sep 2023 16:21:15 +0200 Subject: [PATCH] show-logs: add assert and fix local variable type Follows-up for: 0693e6b246053d31c0eb405c6abe9db8a4d00aaf #29355 --- src/shared/logs-show.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index a574870cb76..77452a81bad 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -412,13 +412,14 @@ static int output_timestamp_realtime( /* No usec in strftime, need to append */ if (mode == OUTPUT_SHORT_ISO_PRECISE) { + assert(ELEMENTSOF(buf) - tail >= 7); snprintf(buf + tail, ELEMENTSOF(buf) - tail, ".%06"PRI_USEC, display_ts->realtime % USEC_PER_SEC); tail += 7; } - int8_t h = tm.tm_gmtoff / 60 / 60; - int8_t m = labs((tm.tm_gmtoff / 60) % 60); - snprintf(buf + tail, ELEMENTSOF(buf) - tail, "%+03"PRId8":%02"PRId8, h, m); + int h = tm.tm_gmtoff / 60 / 60; + int m = labs((tm.tm_gmtoff / 60) % 60); + snprintf(buf + tail, ELEMENTSOF(buf) - tail, "%+03d:%02d", h, m); break; } -- 2.47.3