summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2012-09-01 10:56:15 +0000
committered <ed@FreeBSD.org>2012-09-01 10:56:15 +0000
commit79fa964314bead3dd00a1a411724f8446667a8bc (patch)
treeb7ba2b2f8c87351532d4a47d18e8a7de91ab07ef /usr.sbin
parent12303b5db53ad5e4e7600440f16031789eb98c64 (diff)
downloadFreeBSD-src-79fa964314bead3dd00a1a411724f8446667a8bc.zip
FreeBSD-src-79fa964314bead3dd00a1a411724f8446667a8bc.tar.gz
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
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/lmcconfig/lmcconfig.c15
1 files changed, 7 insertions, 8 deletions
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);
OpenPOWER on IntegriCloud