]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
bindings: Adjusts the logic for calculating SwapFree to better handle conditions...
authorKellen Renshaw <kellen.renshaw@canonical.com>
Tue, 28 Jan 2020 00:57:58 +0000 (17:57 -0700)
committerKellen Renshaw <kellen.renshaw@canonical.com>
Tue, 28 Jan 2020 00:57:58 +0000 (17:57 -0700)
Signed-off-by: Kellen Renshaw <kellen.renshaw@canonical.com>
bindings.c

index d11f0e5baacb4d872cb0facbb4e3aeee2f96f82d..4a8a42181822be459e6117443e1d489b3e3bd3a3 100644 (file)
@@ -3599,7 +3599,7 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
                        printme = lbuf;
                } else if (startswith(line, "SwapFree:") && memswlimit > 0 && memswusage > 0 && opts && opts->swap_off == false) {
                        unsigned long swaptotal = memswlimit,
-                                       swapusage = memswusage - memusage,
+                                       swapusage = memusage > memswusage ? 0 : memswusage - memusage,
                                        swapfree = swapusage < swaptotal ? swaptotal - swapusage : 0;
                        snprintf(lbuf, 100, "SwapFree:       %8lu kB\n", swapfree);
                        printme = lbuf;