From 47af06b52b41c470a56044851673ca646a1311e1 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 11 Mar 2019 00:00:00 -0500 Subject: [PATCH] library: repair any broken stuff found during refactor Rather than offer three separate patches, they've been consolidated in this single commit. All are related in that they surfaced while preparing a subsequent patch. ------------------------------------------------------ library: correct a broken '#if define', api It was introduced (embarrassingly) in the patch below. Reference(s): commit 97d078a9afbe4ed9949dc71acf7091fcf7971339 ------------------------------------------------------ library: correct a broken 'GET' macro, api In the patch referenced below, which purported to make all the 'GET' macros robust, the 'DISKSTATS_GET' macro was broken. A necessary parameter wasn't passed to the subsequently invoked function: procps_diskstats_get(). Reference(s): commit bef8c7fb70164091071c792016371869b9c50ad2 ------------------------------------------------------ library: correct a broken 'sort' func, api In the commit shown below, an attempt to normalize the errno handling, the sort function inadvertently lost 1 crucial line of code which produces a consistent SEGV. Reference(s): commit 06be33b43e5ff3f2658e77ef79441ac2e970cfd7 Signed-off-by: Jim Warner --- proc/diskstats.c | 2 ++ proc/diskstats.h | 2 +- proc/slabinfo.c | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/proc/diskstats.c b/proc/diskstats.c index e935bb3c..134f6e01 100644 --- a/proc/diskstats.c +++ b/proc/diskstats.c @@ -989,7 +989,9 @@ PROCPS_EXPORT struct diskstats_stack **procps_diskstats_sort ( } errno = 0; + parms.offset = offset; parms.order = order; + qsort_r(stacks, numstacked, sizeof(void *), (QSR_t)Item_table[p->item].sortfunc, &parms); return stacks; } // end: procps_diskstats_sort diff --git a/proc/diskstats.h b/proc/diskstats.h index 92195c3d..8b9b8d00 100644 --- a/proc/diskstats.h +++ b/proc/diskstats.h @@ -91,7 +91,7 @@ struct diskstats_reap { #define DISKSTATS_TYPE_PARTITION -22222 #define DISKSTATS_GET( info, name, actual_enum, type ) ( { \ - struct diskstats_result *r = procps_diskstats_get( info, actual_enum ); \ + struct diskstats_result *r = procps_diskstats_get( info, name, actual_enum ); \ r ? r->result . type : 0; } ) #define DISKSTATS_VAL( relative_enum, type, stack, info ) \ diff --git a/proc/slabinfo.c b/proc/slabinfo.c index 4049c1a8..d1c4f98f 100644 --- a/proc/slabinfo.c +++ b/proc/slabinfo.c @@ -584,6 +584,7 @@ static void slabinfo_itemize_stacks_all ( static inline int slabinfo_items_check_failed ( + struct ext_support *this, enum slabinfo_item *items, int numitems) { @@ -615,6 +616,7 @@ static inline int slabinfo_items_check_failed ( return 1; if (items[i] >= SLABINFO_logical_end) return 1; + (void)this; #endif } @@ -741,7 +743,7 @@ static int slabinfo_stacks_reconfig_maybe ( enum slabinfo_item *items, int numitems) { - if (slabinfo_items_check_failed(items, numitems)) + if (slabinfo_items_check_failed(this, items, numitems)) return -1; /* is this the first time or have things changed since we were last called? if so, gotta' redo all of our stacks stuff ... */