From eff9fbc06e0f86a8ac84542616fa4f55e1f96331 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Fri, 1 Jul 2016 00:00:00 -0500 Subject: [PATCH] library: standardize extents_free_all() logic, 3rd gen As those 3rd generation newlib APIs evolved so too did the extents_free_all() function. Most versions of this function required the callers to first verify that the extents anchor wasn't empty, which was poor etiquette. This simple function should have been much more robust and forgiving. With this commit, it fnally becomes so. Signed-off-by: Jim Warner --- proc/meminfo.c | 4 ++-- proc/pids.c | 11 ++++------- proc/slabinfo.c | 4 ++-- proc/stat.c | 4 ++-- proc/vmstat.c | 4 ++-- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/proc/meminfo.c b/proc/meminfo.c index 58f78246..9be12d4c 100644 --- a/proc/meminfo.c +++ b/proc/meminfo.c @@ -401,11 +401,11 @@ static inline void cleanup_stacks_all ( static void extents_free_all ( struct procps_meminfo *info) { - do { + while (info->extents) { struct stacks_extent *p = info->extents; info->extents = info->extents->next; free(p); - } while (info->extents); + }; } // end: extents_free_all diff --git a/proc/pids.c b/proc/pids.c index 0f221ff5..adaf477e 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -832,14 +832,11 @@ static struct stacks_extent *extent_cut ( static void extents_free_all ( struct procps_pidsinfo *info) { - struct stacks_extent *ext = info->extents; - - while (ext) { - info->extents = ext->next; - free(ext); - ext = info->extents; + while (info->extents) { + struct stacks_extent *p = info->extents; + info->extents = info->extents->next; + free(p); }; - info->dirty_stacks = 0; } // end: extents_free_all diff --git a/proc/slabinfo.c b/proc/slabinfo.c index 75b8df10..f5dda453 100644 --- a/proc/slabinfo.c +++ b/proc/slabinfo.c @@ -549,11 +549,11 @@ static inline void cleanup_stacks_all ( static void extents_free_all ( struct ext_support *this) { - do { + while (this->extents) { struct stacks_extent *p = this->extents; this->extents = this->extents->next; free(p); - } while (this->extents); + }; } // end: extents_free_all diff --git a/proc/stat.c b/proc/stat.c index 22863f41..1e003f71 100644 --- a/proc/stat.c +++ b/proc/stat.c @@ -319,11 +319,11 @@ static inline void cleanup_stacks_all ( static void extents_free_all ( struct ext_support *this) { - do { + while (this->extents) { struct stacks_extent *p = this->extents; this->extents = this->extents->next; free(p); - } while (this->extents); + }; } // end: extents_free_all diff --git a/proc/vmstat.c b/proc/vmstat.c index f091a3cc..6de294a8 100644 --- a/proc/vmstat.c +++ b/proc/vmstat.c @@ -766,11 +766,11 @@ static inline void cleanup_stacks_all ( static void extents_free_all ( struct procps_vmstat *info) { - do { + while (info->extents) { struct stacks_extent *p = info->extents; info->extents = info->extents->next; free(p); - } while (info->extents); + }; } // end: extents_free_all