Rework time handling.

After I made the previous commit, I noticed the code does some things it
shouldn't. It casts a struct timeval to a time_t, assuming tv_sec is the
first member. Also, we are not interested in microseconds, so it is
better to just call time(NULL).

MFC after:	1 month
This commit is contained in:
ed 2012-09-01 10:56:15 +00:00
parent 12303b5db5
commit 79fa964314

View File

@ -1074,17 +1074,16 @@ print_hssi_sigs(void)
static void
print_events(void)
{
char *time;
struct timeval tv;
const char *reset_time;
time_t now;
gettimeofday(&tv, NULL);
time = (char *)ctime((time_t *)&tv);
printf("Current time:\t\t%s", time);
now = time(NULL);
printf("Current time:\t\t%s", ctime(&now));
if (status.cntrs.reset_time.tv_sec < 1000)
time = "Never\n";
reset_time = "Never\n";
else
time = (char *)ctime((time_t *)&status.cntrs.reset_time.tv_sec);
printf("Cntrs reset:\t\t%s", time);
reset_time = ctime(&status.cntrs.reset_time.tv_sec);
printf("Cntrs reset:\t\t%s", reset_time);
if (status.cntrs.ibytes) printf("Rx bytes:\t\t%ju\n", (uintmax_t)status.cntrs.ibytes);
if (status.cntrs.obytes) printf("Tx bytes:\t\t%ju\n", (uintmax_t)status.cntrs.obytes);