Skip to content

Commit b0df12e

Browse files
committed
status: use %lld to print time_t
Some build configurations are switching to 64-bit time_t, breaking builds on 32-bit architectures. Always use %lld and perform an explicit conversion to (long long int) in order to make the code compile on all architectures. ../status.c: In function 'status_send_values': ../status.c:46:53: error: format '%ld' expects argument of type 'long int', but argument 4 has type '__time64_t' {aka 'long long int'} [-Werror=format=] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 59db294 commit b0df12e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

status.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ void status_send_values(const char *id, struct status_value *values)
4343

4444
status_get_ts(&ts);
4545

46-
len = snprintf(buf, sizeof(buf), "{\"ts\":%ld.%03ld, \"%s\":{ ", ts.tv_sec, ts.tv_nsec / 1000000, id);
46+
len = snprintf(buf, sizeof(buf), "{\"ts\":%lld.%03ld, \"%s\":{ ",
47+
(long long int)ts.tv_sec, ts.tv_nsec / 1000000, id);
4748

4849
for (value = values; value->unit; value++) {
4950
if (value != values) {

0 commit comments

Comments
 (0)