From: наб Date: Thu, 28 Sep 2023 14:21:15 +0000 (+0200) Subject: show-logs: add assert and fix local variable type X-Git-Tag: v255-rc1~398 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e2e0125921490c1b148acbb7c7a19acf6bcad080;p=thirdparty%2Fsystemd.git show-logs: add assert and fix local variable type Follows-up for: 0693e6b246053d31c0eb405c6abe9db8a4d00aaf #29355 --- 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; }