Properly print time differences.
time_t is not necessarily of type int.
This commit is contained in:
@@ -251,14 +251,14 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
|
|||||||
fprintf(out, ", %" PRIu64 " bytes_i", bytes_in);
|
fprintf(out, ", %" PRIu64 " bytes_i", bytes_in);
|
||||||
if (use_in)
|
if (use_in)
|
||||||
{
|
{
|
||||||
fprintf(out, " (%ds ago)", now - use_in);
|
fprintf(out, " (%" PRIu64 "s ago)", (u_int64_t)(now - use_in));
|
||||||
}
|
}
|
||||||
|
|
||||||
child_sa->get_usestats(child_sa, FALSE, &use_out, &bytes_out);
|
child_sa->get_usestats(child_sa, FALSE, &use_out, &bytes_out);
|
||||||
fprintf(out, ", %" PRIu64 " bytes_o", bytes_out);
|
fprintf(out, ", %" PRIu64 " bytes_o", bytes_out);
|
||||||
if (use_out)
|
if (use_out)
|
||||||
{
|
{
|
||||||
fprintf(out, " (%ds ago)", now - use_out);
|
fprintf(out, " (%" PRIu64 "s ago)", (u_int64_t)(now - use_out));
|
||||||
}
|
}
|
||||||
fprintf(out, ", rekeying ");
|
fprintf(out, ", rekeying ");
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@@ -342,7 +343,7 @@ int time_delta_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
|||||||
char* unit = "second";
|
char* unit = "second";
|
||||||
time_t *arg1 = *((time_t**)(args[0]));
|
time_t *arg1 = *((time_t**)(args[0]));
|
||||||
time_t *arg2 = *((time_t**)(args[1]));
|
time_t *arg2 = *((time_t**)(args[1]));
|
||||||
time_t delta = abs(*arg1 - *arg2);
|
u_int64_t delta = llabs(*arg1 - *arg2);
|
||||||
|
|
||||||
if (delta > 2 * 60 * 60 * 24)
|
if (delta > 2 * 60 * 60 * 24)
|
||||||
{
|
{
|
||||||
@@ -359,7 +360,8 @@ int time_delta_printf_hook(char *dst, size_t len, printf_hook_spec_t *spec,
|
|||||||
delta /= 60;
|
delta /= 60;
|
||||||
unit = "minute";
|
unit = "minute";
|
||||||
}
|
}
|
||||||
return print_in_hook(dst, len, "%d %s%s", delta, unit, (delta == 1)? "":"s");
|
return print_in_hook(dst, len, "%" PRIu64 " %s%s", delta, unit,
|
||||||
|
(delta == 1) ? "" : "s");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user