svn commit: r239988 - head/usr.sbin/lmcconfig
Ed Schouten
ed at FreeBSD.org
Sat Sep 1 10:56:16 UTC 2012
Author: ed
Date: Sat Sep 1 10:56:15 2012
New Revision: 239988
URL: http://svn.freebsd.org/changeset/base/239988
Log:
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
Modified:
head/usr.sbin/lmcconfig/lmcconfig.c
Modified: head/usr.sbin/lmcconfig/lmcconfig.c
==============================================================================
--- head/usr.sbin/lmcconfig/lmcconfig.c Sat Sep 1 10:52:19 2012 (r239987)
+++ head/usr.sbin/lmcconfig/lmcconfig.c Sat Sep 1 10:56:15 2012 (r239988)
@@ -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);
More information about the svn-src-head
mailing list