Date: Sat, 1 Sep 2012 10:56:15 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r239988 - head/usr.sbin/lmcconfig Message-ID: <201209011056.q81AuFIs097112@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209011056.q81AuFIs097112>