From 220236a9af91503164c2768b6bcc6e853989f34f Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 13 Jul 2016 00:00:00 -0500 Subject: [PATCH] library: some minor miscellaeous improvements, 3rd gen A collection of miscellaneous code and comment tweaks. [ such changes will stop when desk checking ends too ] Signed-off-by: Jim Warner --- proc/meminfo.c | 11 ++++++----- proc/pids.c | 3 ++- proc/slabinfo.c | 9 +++++---- proc/stat.c | 9 +++++---- proc/vmstat.c | 11 ++++++----- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/proc/meminfo.c b/proc/meminfo.c index 0a7b4055..a00d8b22 100644 --- a/proc/meminfo.c +++ b/proc/meminfo.c @@ -574,6 +574,7 @@ static int read_meminfo_failed ( buf[size] = '\0'; head = buf; + for (;;) { static ENTRY e; // just to keep coverity off our backs (e.data) ENTRY *ep; @@ -595,7 +596,6 @@ static int read_meminfo_failed ( tail = strchr(head, '\n'); if (!tail) break; - head = tail + 1; } @@ -628,10 +628,10 @@ static int read_meminfo_failed ( mHr(derived_swap_used) = mHr(SwapTotal) - mHr(SwapFree); // let's not distort the deltas the first time thru ... - if (!info->meminfo_was_read) + if (!info->meminfo_was_read) { memcpy(&info->hist.old, &info->hist.new, sizeof(struct meminfo_data)); - info->meminfo_was_read = 1; - + info->meminfo_was_read = 1; + } return 0; #undef mHr } // end: read_meminfo_failed @@ -710,7 +710,8 @@ static struct stacks_extent *stacks_alloc ( * The initial refcount is 1, and needs to be decremented * to release the resources of the structure. * - * Returns: a pointer to a new meminfo struct + * Returns: < 0 on failure, 0 on success along with + * a pointer to a new context struct */ PROCPS_EXPORT int procps_meminfo_new ( struct procps_meminfo **info) diff --git a/proc/pids.c b/proc/pids.c index 0881c66d..a9e730a4 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -1117,7 +1117,8 @@ static int stacks_fetch ( * * @info: location of returned new structure * - * Returns: 0 on success <0 on failure + * Returns: < 0 on failure, 0 on success along with + * a pointer to a new context struct */ PROCPS_EXPORT int procps_pids_new ( struct procps_pidsinfo **info, diff --git a/proc/slabinfo.c b/proc/slabinfo.c index 85f03c57..88f86faa 100644 --- a/proc/slabinfo.c +++ b/proc/slabinfo.c @@ -491,10 +491,10 @@ static int read_slabinfo_failed ( else return -ERANGE; - if (!info->slabinfo_was_read) + if (!info->slabinfo_was_read) { memcpy(&info->hist.old, &info->hist.new, sizeof(struct slabs_summ)); - info->slabinfo_was_read = 1; - + info->slabinfo_was_read = 1; + } return retval; } // end: read_slabinfo_failed @@ -773,7 +773,8 @@ static int stacks_reconfig_maybe ( * * @info: location of returned new structure * - * Returns: 0 on success <0 on failure + * Returns: < 0 on failure, 0 on success along with + * a pointer to a new context struct */ PROCPS_EXPORT int procps_slabinfo_new ( struct procps_slabinfo **info) diff --git a/proc/stat.c b/proc/stat.c index f0437fa6..a696a665 100644 --- a/proc/stat.c +++ b/proc/stat.c @@ -577,10 +577,10 @@ reap_em_again: info->sys_hist.new.procs_running = llnum; // let's not distort the deltas the first time thru ... - if (!info->stat_was_read) + if (!info->stat_was_read) { memcpy(&info->sys_hist.old, &info->sys_hist.new, sizeof(struct stat_data)); - - info->stat_was_read = 1; + info->stat_was_read = 1; + } return 0; } // end: read_stat_failed @@ -769,7 +769,8 @@ static struct stat_stack *update_single_stack ( * The initial refcount is 1, and needs to be decremented * to release the resources of the structure. * - * Returns: a new stat info container + * Returns: < 0 on failure, 0 on success along with + * a pointer to a new context struct */ PROCPS_EXPORT int procps_stat_new ( struct procps_statinfo **info) diff --git a/proc/vmstat.c b/proc/vmstat.c index 7d0012e8..c0c8603d 100644 --- a/proc/vmstat.c +++ b/proc/vmstat.c @@ -999,6 +999,7 @@ static int read_vmstat_failed ( buf[size] = '\0'; head = buf; + for (;;) { static ENTRY e; // just to keep coverity off our backs (e.data) ENTRY *ep; @@ -1020,15 +1021,14 @@ static int read_vmstat_failed ( tail = strchr(head, '\n'); if (!tail) break; - head = tail + 1; } // let's not distort the deltas the first time thru ... - if (!info->vmstat_was_read) + if (!info->vmstat_was_read) { memcpy(&info->hist.old, &info->hist.new, sizeof(struct vmstat_data)); - info->vmstat_was_read = 1; - + info->vmstat_was_read = 1; + } return 0; } // end: read_vmstat_failed @@ -1106,7 +1106,8 @@ static struct stacks_extent *stacks_alloc ( * The initial refcount is 1, and needs to be decremented * to release the resources of the structure. * - * Returns: a pointer to a new vmstatinfo struct + * Returns: < 0 on failure, 0 on success along with + * a pointer to a new context struct */ PROCPS_EXPORT int procps_vmstat_new ( struct procps_vmstat **info)