X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdaemon%2Futils_time.c;fp=src%2Fdaemon%2Futils_time.c;h=5d905d9b7c2dbe9fad9fcf6e45ad027a0e56947b;hb=20d15cfd26b23508242abcead906207bf26175d0;hp=6603c15e89f161afc832a5e2cd8ef08b335564ea;hpb=c0a95e555ed8b58af9ff9e476ce1c13241a21ae3;p=collectd.git diff --git a/src/daemon/utils_time.c b/src/daemon/utils_time.c index 6603c15e..5d905d9b 100644 --- a/src/daemon/utils_time.c +++ b/src/daemon/utils_time.c @@ -89,11 +89,13 @@ size_t cdtime_to_iso8601 (char *s, size_t max, cdtime_t t) /* {{{ */ if (max - len > 2) { int n = snprintf (s + len, max - len, ".%09i", (int)t_spec.tv_nsec); - len += (n < max - len) ? n : max - len; + len += (n < 0) ? 0 + : (((size_t) n) < (max - len)) ? ((size_t) n) + : (max - len); } if (max - len > 3) { - int n = strftime (s + len, max - len, "%z", &t_tm); + size_t n = strftime (s + len, max - len, "%z", &t_tm); len += (n < max - len) ? n : max - len; }