diff options
author | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2024-05-06 16:54:23 +0000 |
---|---|---|
committer | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2024-05-06 16:54:23 +0000 |
commit | b06bb785ccac878f3b411cd86a347359c1990612 (patch) | |
tree | 951500932e9f3c3bf7bc9ee114c6dfe1d88a8bf1 | |
parent | d9ef9c32403b26c583c9e6212787dd2a89530fab (diff) |
vmstat/dkstats.c: remove obfuscatory timerset() macro
Using a macro to perform a plain struct assignment obfuscates the
obvious. Delete the timerset() macro.
While here, remove some superfluous timerclear(3) calls.
Thread: https://marc.info/?l=openbsd-tech&m=171346446031940&w=2
ok millert@
-rw-r--r-- | usr.bin/vmstat/dkstats.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c index df4e8d50b41..b52825669e9 100644 --- a/usr.bin/vmstat/dkstats.c +++ b/usr.bin/vmstat/dkstats.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkstats.c,v 1.41 2019/06/28 13:35:05 deraadt Exp $ */ +/* $OpenBSD: dkstats.c,v 1.42 2024/05/06 16:54:22 cheloha Exp $ */ /* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */ /* @@ -101,11 +101,6 @@ int dk_ndrive = 0; int *dk_select; char **dr_name; -/* Missing from <sys/time.h> */ -#define timerset(tvp, uvp) \ - ((uvp)->tv_sec = (tvp)->tv_sec); \ - ((uvp)->tv_usec = (tvp)->tv_usec) - #define SWAP(fld) tmp = cur.fld; \ cur.fld -= last.fld; \ last.fld = tmp @@ -135,11 +130,9 @@ dkswap(void) SWAP(dk_wbytes[i]); /* Delta Time. */ - timerclear(&tmp_timer); - timerset(&(cur.dk_time[i]), &tmp_timer); - timersub(&tmp_timer, &(last.dk_time[i]), &(cur.dk_time[i])); - timerclear(&(last.dk_time[i])); - timerset(&tmp_timer, &(last.dk_time[i])); + tmp_timer = cur.dk_time[i]; + timersub(&tmp_timer, &last.dk_time[i], &cur.dk_time[i]); + last.dk_time[i] = tmp_timer; } for (i = 0; i < CPUSTATES; i++) { long ltmp; @@ -370,7 +363,7 @@ dkreadstats(void) cur.dk_seek[i] = q[i].ds_seek; cur.dk_rbytes[i] = q[i].ds_rbytes; cur.dk_wbytes[i] = q[i].ds_wbytes; - timerset(&(q[i].ds_time), &(cur.dk_time[i])); + cur.dk_time[i] = q[i].ds_time; } free(q); @@ -408,7 +401,7 @@ dkreadstats(void) cur.dk_seek[i] = cur_disk.dk_seek; cur.dk_rbytes[i] = cur_disk.dk_rbytes; cur.dk_wbytes[i] = cur_disk.dk_wbytes; - timerset(&(cur_disk.dk_time), &(cur.dk_time[i])); + cur.dk_time[i] = cur_disk.dk_time; p = TAILQ_NEXT(&cur_disk, dk_link); } deref_nl(X_CP_TIME, cur.cp_time, sizeof(cur.cp_time)); |