diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/logs-show.c | 6 | ||||
-rw-r--r-- | src/shared/time-util.c | 24 | ||||
-rw-r--r-- | src/shared/time-util.h | 38 |
3 files changed, 34 insertions, 34 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index c3578ac918..8edf4087c6 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -301,8 +301,8 @@ static int output_short( } fprintf(f, "[%5llu.%06llu]", - t / USEC_PER_SEC, - t % USEC_PER_SEC); + (unsigned long long) (t / USEC_PER_SEC), + (unsigned long long) (t % USEC_PER_SEC)); n += 1 + 5 + 1 + 6 + 1; @@ -335,7 +335,7 @@ static int output_short( r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", localtime_r(&t, &tm)); if (r > 0) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), - ".%06llu", x % USEC_PER_SEC); + ".%06llu", (unsigned long long) (x % USEC_PER_SEC)); } break; default: diff --git a/src/shared/time-util.c b/src/shared/time-util.c index c66763872d..8e5de77757 100644 --- a/src/shared/time-util.c +++ b/src/shared/time-util.c @@ -183,7 +183,7 @@ char *format_timestamp_us(char *buf, size_t l, usec_t t) { if (strftime(buf, l, "%a %Y-%m-%d %H:%M:%S", &tm) <= 0) return NULL; - snprintf(buf + strlen(buf), l - strlen(buf), ".%06llu", t % USEC_PER_SEC); + snprintf(buf + strlen(buf), l - strlen(buf), ".%06llu", (unsigned long long) (t % USEC_PER_SEC)); if (strftime(buf + strlen(buf), l - strlen(buf), " %Z", &tm) <= 0) return NULL; @@ -208,41 +208,41 @@ char *format_timestamp_relative(char *buf, size_t l, usec_t t) { } if (d >= USEC_PER_YEAR) - snprintf(buf, l, "%llu years %llu months %s", + snprintf(buf, l, USEC_FMT " years " USEC_FMT " months %s", d / USEC_PER_YEAR, (d % USEC_PER_YEAR) / USEC_PER_MONTH, s); else if (d >= USEC_PER_MONTH) - snprintf(buf, l, "%llu months %llu days %s", + snprintf(buf, l, USEC_FMT " months " USEC_FMT " days %s", d / USEC_PER_MONTH, (d % USEC_PER_MONTH) / USEC_PER_DAY, s); else if (d >= USEC_PER_WEEK) - snprintf(buf, l, "%llu weeks %llu days %s", + snprintf(buf, l, USEC_FMT " weeks " USEC_FMT " days %s", d / USEC_PER_WEEK, (d % USEC_PER_WEEK) / USEC_PER_DAY, s); else if (d >= 2*USEC_PER_DAY) - snprintf(buf, l, "%llu days %s", d / USEC_PER_DAY, s); + snprintf(buf, l, USEC_FMT " days %s", d / USEC_PER_DAY, s); else if (d >= 25*USEC_PER_HOUR) - snprintf(buf, l, "1 day %lluh %s", + snprintf(buf, l, "1 day " USEC_FMT "h %s", (d - USEC_PER_DAY) / USEC_PER_HOUR, s); else if (d >= 6*USEC_PER_HOUR) - snprintf(buf, l, "%lluh %s", + snprintf(buf, l, USEC_FMT "h %s", d / USEC_PER_HOUR, s); else if (d >= USEC_PER_HOUR) - snprintf(buf, l, "%lluh %llumin %s", + snprintf(buf, l, USEC_FMT "h " USEC_FMT "min %s", d / USEC_PER_HOUR, (d % USEC_PER_HOUR) / USEC_PER_MINUTE, s); else if (d >= 5*USEC_PER_MINUTE) - snprintf(buf, l, "%llumin %s", + snprintf(buf, l, USEC_FMT "min %s", d / USEC_PER_MINUTE, s); else if (d >= USEC_PER_MINUTE) - snprintf(buf, l, "%llumin %llus %s", + snprintf(buf, l, USEC_FMT "min " USEC_FMT "s %s", d / USEC_PER_MINUTE, (d % USEC_PER_MINUTE) / USEC_PER_SEC, s); else if (d >= USEC_PER_SEC) - snprintf(buf, l, "%llus %s", + snprintf(buf, l, USEC_FMT "s %s", d / USEC_PER_SEC, s); else if (d >= USEC_PER_MSEC) - snprintf(buf, l, "%llums %s", + snprintf(buf, l, USEC_FMT "ms %s", d / USEC_PER_MSEC, s); else if (d > 0) snprintf(buf, l, USEC_FMT"us %s", diff --git a/src/shared/time-util.h b/src/shared/time-util.h index 96f2ec8fa3..f68c095605 100644 --- a/src/shared/time-util.h +++ b/src/shared/time-util.h @@ -37,25 +37,25 @@ typedef struct dual_timestamp { usec_t monotonic; } dual_timestamp; -#define MSEC_PER_SEC 1000ULL -#define USEC_PER_SEC 1000000ULL -#define USEC_PER_MSEC 1000ULL -#define NSEC_PER_SEC 1000000000ULL -#define NSEC_PER_MSEC 1000000ULL -#define NSEC_PER_USEC 1000ULL - -#define USEC_PER_MINUTE (60ULL*USEC_PER_SEC) -#define NSEC_PER_MINUTE (60ULL*NSEC_PER_SEC) -#define USEC_PER_HOUR (60ULL*USEC_PER_MINUTE) -#define NSEC_PER_HOUR (60ULL*NSEC_PER_MINUTE) -#define USEC_PER_DAY (24ULL*USEC_PER_HOUR) -#define NSEC_PER_DAY (24ULL*NSEC_PER_HOUR) -#define USEC_PER_WEEK (7ULL*USEC_PER_DAY) -#define NSEC_PER_WEEK (7ULL*NSEC_PER_DAY) -#define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC) -#define NSEC_PER_MONTH (2629800ULL*NSEC_PER_SEC) -#define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC) -#define NSEC_PER_YEAR (31557600ULL*NSEC_PER_SEC) +#define MSEC_PER_SEC ((usec_t) 1000ULL) +#define USEC_PER_SEC ((usec_t) 1000000ULL) +#define USEC_PER_MSEC ((usec_t) 1000ULL) +#define NSEC_PER_SEC ((usec_t) 1000000000ULL) +#define NSEC_PER_MSEC ((usec_t) 1000000ULL) +#define NSEC_PER_USEC ((usec_t) 1000ULL) + +#define USEC_PER_MINUTE ((usec_t) (60ULL*USEC_PER_SEC)) +#define NSEC_PER_MINUTE ((usec_t) (60ULL*NSEC_PER_SEC)) +#define USEC_PER_HOUR ((usec_t) (60ULL*USEC_PER_MINUTE)) +#define NSEC_PER_HOUR ((usec_t) (60ULL*NSEC_PER_MINUTE)) +#define USEC_PER_DAY ((usec_t) (24ULL*USEC_PER_HOUR)) +#define NSEC_PER_DAY ((usec_t) (24ULL*NSEC_PER_HOUR)) +#define USEC_PER_WEEK ((usec_t) (7ULL*USEC_PER_DAY)) +#define NSEC_PER_WEEK ((usec_t) (7ULL*NSEC_PER_DAY)) +#define USEC_PER_MONTH ((usec_t) (2629800ULL*USEC_PER_SEC)) +#define NSEC_PER_MONTH ((usec_t) (2629800ULL*NSEC_PER_SEC)) +#define USEC_PER_YEAR ((usec_t) (31557600ULL*USEC_PER_SEC)) +#define NSEC_PER_YEAR ((usec_t) (31557600ULL*NSEC_PER_SEC)) #define FORMAT_TIMESTAMP_MAX ((4*4+1)+11+9+4+1) /* weekdays can be unicode */ #define FORMAT_TIMESTAMP_RELATIVE_MAX 256 |