diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-06-05 06:34:45 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2006-06-05 06:34:45 +0000 |
commit | 6274e12d024541bb7fa5dc0d7e6aa0693b4e98f1 (patch) | |
tree | c73420d703b8f2d5e9a33987d03d137ddd238655 /sbin/sysctl/sysctl.c | |
parent | 0fb0231ec64d2e0c886666a58f7539ee10106fb1 (diff) |
Simpler code for printing time sensors: no leak and no floating
point. ok deraadt@
Diffstat (limited to 'sbin/sysctl/sysctl.c')
-rw-r--r-- | sbin/sysctl/sysctl.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index ceda909d9e9..99af79eac2e 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.140 2006/06/04 01:34:48 deraadt Exp $ */ +/* $OpenBSD: sysctl.c,v 1.141 2006/06/05 06:34:44 otto Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95"; #else -static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.140 2006/06/04 01:34:48 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: sysctl.c,v 1.141 2006/06/05 06:34:44 otto Exp $"; #endif #endif /* not lint */ @@ -2216,17 +2216,11 @@ print_sensor(struct sensor *s) if (s->tv.tv_sec) { time_t t = s->tv.tv_sec; - char decimal[10]; - char *ct; - - ct = ctime(&t); - if (ct) { - ct = strdup(ct); - ct[19] = '\0'; - snprintf(decimal, sizeof decimal, "%.3f", - s->tv.tv_usec / 1000000.0); - printf(", %s%s", ct, decimal+1); - } + char ct[26]; + + ctime_r(&t, ct); + ct[19] = '\0'; + printf(", %s.%03ld", ct, s->tv.tv_usec / 1000); } } |