From 79fa964314bead3dd00a1a411724f8446667a8bc Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 1 Sep 2012 10:56:15 +0000 Subject: 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 --- usr.sbin/lmcconfig/lmcconfig.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'usr.sbin/lmcconfig') diff --git a/usr.sbin/lmcconfig/lmcconfig.c b/usr.sbin/lmcconfig/lmcconfig.c index e820a91..7fbc216 100644 --- a/usr.sbin/lmcconfig/lmcconfig.c +++ b/usr.sbin/lmcconfig/lmcconfig.c @@ -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); -- cgit v1.1