]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
show-logs: add assert and fix local variable type
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Thu, 28 Sep 2023 14:21:15 +0000 (16:21 +0200)
committerGitHub <noreply@github.com>
Thu, 28 Sep 2023 14:21:15 +0000 (15:21 +0100)
Follows-up for: 0693e6b246053d31c0eb405c6abe9db8a4d00aaf

#29355

src/shared/logs-show.c

index a574870cb76ed49299cbeed20570e4c162a64993..77452a81bad92e17df08d832385423b6dcc4e6ac 100644 (file)
@@ -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;
                 }