From d903bff67f67fe7ff8a2f441cadf745434d93a4e Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Tue, 22 Dec 2020 12:22:30 +0100 Subject: [PATCH] sar: Fix return code sent by write_stats() function Make sure that a line of statistics has actually been displayed to return 1 for the status code value. When an activity has no item at all for current sample, we should not return a status code of 1 else we won't display the header line for next sample. Signed-off-by: Sebastien GODARD --- sar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sar.c b/sar.c index 5d36ebd..4dc6a8d 100644 --- a/sar.c +++ b/sar.c @@ -435,7 +435,7 @@ void write_stats_avg(int curr, int read_from_file, unsigned int act_id) int write_stats(int curr, int read_from_file, long *cnt, int use_tm_start, int use_tm_end, int reset, unsigned int act_id, int reset_cd) { - int i, prev_hour; + int i, prev_hour, rc = 0; unsigned long long itv; static int cross_day = FALSE; @@ -514,10 +514,11 @@ int write_stats(int curr, int read_from_file, long *cnt, int use_tm_start, if (IS_SELECTED(act[i]->options) && (act[i]->nr[curr] > 0)) { /* Display current activity statistics */ (*act[i]->f_print)(act[i], !curr, curr, itv); + rc = 1; } } - return 1; + return rc; } /* @@ -701,7 +702,6 @@ void read_sadc_stat_bunch(int curr) reallocate_all_buffers(act[p], act[p]->nr[curr]); } - /* * For persistent activities, we must make sure that no statistics * from a previous iteration remain, especially if the number -- 2.40.0