summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Klausner <wiz@gatalith.at>2022-08-18 19:16:05 +0200
committerGitHub <noreply@github.com>2022-08-18 19:16:05 +0200
commit84219ad536370eda325d27947831be270e7077b0 (patch)
tree9891bb1f7478453b0748e7b4dbdcb2ce43541410
parentdf3fba560125a1694140418458d85076ebc546fd (diff)
downloadpsutil-84219ad536370eda325d27947831be270e7077b0.tar.gz
[NetBSD] two fixes for swap code (#2128)
-rw-r--r--CREDITS2
-rw-r--r--HISTORY.rst1
-rw-r--r--psutil/arch/netbsd/specific.c6
3 files changed, 5 insertions, 4 deletions
diff --git a/CREDITS b/CREDITS
index 61e75453..c697e214 100644
--- a/CREDITS
+++ b/CREDITS
@@ -85,7 +85,7 @@ I: 18
N: Thomas Klausner
W: https://github.com/0-wiz-0
D: NetBSD implementation (co-author).
-I: 557
+I: 557, 2128
N: Ryo Onodera
W: https://github.com/ryoon
diff --git a/HISTORY.rst b/HISTORY.rst
index d4c68192..7c99a4f6 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,7 @@
- 2113, [FreeBSD]: __FreeBSD_version used in mem.c without including
<sys/param.h>
+- 2128, [NetBSD]: fix bugs in swap code
5.9.1
=====
diff --git a/psutil/arch/netbsd/specific.c b/psutil/arch/netbsd/specific.c
index 4e286e5e..11b8c1dd 100644
--- a/psutil/arch/netbsd/specific.c
+++ b/psutil/arch/netbsd/specific.c
@@ -459,7 +459,7 @@ psutil_virtual_mem(PyObject *self, PyObject *args) {
(unsigned long long) uv.active << uv.pageshift, // active
(unsigned long long) uv.inactive << uv.pageshift, // inactive
(unsigned long long) uv.wired << uv.pageshift, // wired
- (unsigned long long) uv.filepages + uv.execpages * pagesize, // cached
+ (unsigned long long) (uv.filepages + uv.execpages) * pagesize, // cached
// These are determined from /proc/meminfo in Python.
(unsigned long long) 0, // buffers
(unsigned long long) 0 // shared
@@ -495,8 +495,8 @@ psutil_swap_mem(PyObject *self, PyObject *args) {
swap_total = swap_free = 0;
for (i = 0; i < nswap; i++) {
if (swdev[i].se_flags & SWF_ENABLE) {
- swap_total += swdev[i].se_nblks * DEV_BSIZE;
- swap_free += (swdev[i].se_nblks - swdev[i].se_inuse) * DEV_BSIZE;
+ swap_total += (uint64_t)swdev[i].se_nblks * DEV_BSIZE;
+ swap_free += (uint64_t)(swdev[i].se_nblks - swdev[i].se_inuse) * DEV_BSIZE;
}
}
free(swdev);