From: Sebastien GODARD Date: Tue, 26 Dec 2017 15:56:15 +0000 (+0100) Subject: sadf: Don't test for activities available in file if only the header X-Git-Tag: v11.7.1~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb8fd18886e3533319878faa37f9fb07cac59b7d;p=sysstat 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 --- 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);