summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-07-16 15:14:34 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-07-16 15:14:34 +0000
commit3f377a855ee835de3311ea426f7a18615736e4b9 (patch)
treea93cbaf58fce552d4d65eb0f5b04e8b83dd5186e /usr.bin
parentc1b9a23d760ce2fa2dd4ee9d1e8fe82b16219ac6 (diff)
fix percentage computation of wrapping numbers; from Willem Dijkstra
via henning@ with a twist by me
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/top/utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/top/utils.c b/usr.bin/top/utils.c
index edd111c659c..317124c5700 100644
--- a/usr.bin/top/utils.c
+++ b/usr.bin/top/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.18 2007/04/04 19:22:46 otto Exp $ */
+/* $OpenBSD: utils.c,v 1.19 2007/07/16 15:14:33 otto Exp $ */
/*
* Top users/processes display for Unix
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <stdint.h>
#include "top.h"
#include "machine.h"
@@ -226,7 +227,7 @@ percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_t *diffs)
for (i = 0; i < cnt; i++) {
if ((change = *new - *old) < 0) {
/* this only happens when the counter wraps */
- change = (*new - *old);
+ change = INT64_MAX - *old + *new;
}
total_change += (*dp++ = change);
*old++ = *new++;