]> granicus.if.org Git - procps-ng/commitdiff
slabtop: let's stop always ignoring the last slab node
authorJim Warner <james.warner@comcast.net>
Thu, 30 Nov 2017 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Wed, 20 Dec 2017 10:07:54 +0000 (21:07 +1100)
This patch will fix a fencepost error that has existed
since at least 2004, the result of which was to always
completely ignore that last merged / sorted slab node.

[ Of course, little harm was done since output would ]
[ have been limited to a terminal's height. Thus, it ]
[ would have required a huge display before noticed. ]

[ But, now that the run once switch shows everything ]
[ such an omission would become really unforgivable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
slabtop.c

index c0bf54f716c1d09655d0131b4421b237dc66486e..80be0a9d79a58454d22e870fc687031f520e9192 100644 (file)
--- a/slabtop.c
+++ b/slabtop.c
@@ -410,7 +410,7 @@ int main(int argc, char *argv[])
                attroff(A_REVERSE);
 
                curr = slab_list;
-               for (i = 0; i < rows - 8 && curr->next; i++) {
+               for (i = 0; i < rows - 8 && curr; i++) {
                        print_line("%6u %6u %3u%% %7.2fK %6u %8u %9uK %-23s\n",
                                curr->nr_objs, curr->nr_active_objs, curr->use,
                                curr->obj_size / 1024.0, curr->nr_slabs,