From 72307dc710d1300f40f62bab025b9a794f1e5d08 Mon Sep 17 00:00:00 2001 From: Martin Jansa Date: Fri, 1 Jun 2018 15:22:28 +0000 Subject: time-util: fix build with gcc8 -Werror=format-truncation= * it fails with gcc8 when -O1 or -Os is used (and -ftree-vrp which is added by -O2 and higher isn't used) ../git/src/basic/time-util.c: In function 'format_timespan': ../git/src/basic/time-util.c:508:46: error: '%0*llu' directive output between 1 and 2147483647 bytes may cause result to exceed 'INT_MAX' [-Werror=format-truncation=] "%s"USEC_FMT".%0*"PRI_USEC"%s", ^~~~ ../git/src/basic/time-util.c:508:60: note: format string is defined here "%s"USEC_FMT".%0*"PRI_USEC"%s", ../git/src/basic/time-util.c:508:46: note: directive argument in the range [0, 18446744073709551614] "%s"USEC_FMT".%0*"PRI_USEC"%s", ^~~~ ../git/src/basic/time-util.c:507:37: note: 'snprintf' output 4 or more bytes (assuming 2147483651) into a destination of size 4294967295 k = snprintf(p, l, ^~~~~~~~~~~~~~ "%s"USEC_FMT".%0*"PRI_USEC"%s", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p > buf ? " " : "", ~~~~~~~~~~~~~~~~~~~ a, ~~ j, ~~ b, ~~ table[i].suffix); ~~~~~~~~~~~~~~~~ cc1: some warnings being treated as errors [zj: change 'char' to 'signed char'] --- src/basic/time-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 734844731..dc8db13c2 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -494,7 +494,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) { /* Let's see if we should shows this in dot notation */ if (t < USEC_PER_MINUTE && b > 0) { usec_t cc; - int j; + signed char j; j = 0; for (cc = table[i].usec; cc > 1; cc /= 10) -- cgit v1.2.3