From bb8fd18886e3533319878faa37f9fb07cac59b7d Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Tue, 26 Dec 2017 16:56:15 +0100 Subject: [PATCH] sadf: Don't test for activities available in file if only the header needs to be displayed When "sadf -H" is used, there is no need to check that activities exist in file. This is all the more true now as even CPU statistics (A_CPU activity) don't necessarily exist in file. E.g.: sadc -S 0,36 datafile 1 2 Then "sadf -H datafile" should not display error message "Requested activities not available in file". Signed-off-by: Sebastien GODARD --- sa_common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sa_common.c b/sa_common.c index 8e83641..18f57af 100644 --- a/sa_common.c +++ b/sa_common.c @@ -1720,7 +1720,13 @@ void check_file_actlst(int *ifd, char *dfile, struct activity *act[], act[i]->options &= ~AO_SELECTED; } } - if (!get_activity_nr(act, AO_SELECTED, COUNT_ACTIVITIES)) { + + /* + * None of selected activities exist in file: Abort. + * NB: Error is ignored if we only want to display + * datafile header (sadf -H). + */ + if (!get_activity_nr(act, AO_SELECTED, COUNT_ACTIVITIES) && !ignore) { fprintf(stderr, _("Requested activities not available in file %s\n"), dfile); close(*ifd); -- 2.50.1