Fix RAM component on FreeBSD
authormichaelbuch12@gmail.com <michaelbuch12@gmail.com>
Fri, 1 Jan 2021 16:04:36 +0000 (17:04 +0100)
committerdrkhsh <me@drkhsh.at>
Wed, 26 Oct 2022 19:24:11 +0000 (21:24 +0200)
The current implementation uses the wrong type for
given sysctl calls leading to overflow and incorrectly
reported RAM usage. The fix is to use 'unsigned int'
which is what FreeBSD expects.

components/ram.c

index 47e6fdac9b637e885a1fe1c3e7c9107d3f2b64d8..6040e5659355a1d719cb2138dfd741492e498f22 100644 (file)
 
        const char *
        ram_total(void) {
-               long npages;
+               unsigned int npages;
                size_t len;
 
                len = sizeof(npages);
 
        const char *
        ram_perc(void) {
-               long npages;
-               long active;
+               unsigned int npages;
+               unsigned int active;
                size_t len;
 
                len = sizeof(npages);
 
        const char *
        ram_used(void) {
-               long active;
+               unsigned int active;
                size_t len;
 
                len = sizeof(active);