From 23d448557bddb867a7743dee9e9043351636ea21 Mon Sep 17 00:00:00 2001 From: cheloha Date: Mon, 6 May 2024 16:54:22 +0000 Subject: [PATCH] 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@ --- usr.bin/vmstat/dkstats.c | 19 ++++++------------- 1 file 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 */ -#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));