From: Sebastien GODARD Date: Sun, 20 Nov 2016 09:31:41 +0000 (+0100) Subject: sar: Rework option -P parsing X-Git-Tag: v11.5.3~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=607cfca4f089ece33dcbaeef207dd82c834dd265;p=sysstat sar: Rework option -P parsing It is no longer possibe to specify individual CPUs and also to use keyword ALL together (e.g. sar -P ALL,0,2) which is meaningless. Signed-off-by: Sebastien GODARD --- diff --git a/sa_common.c b/sa_common.c index 0570429..9a2c4e7 100644 --- a/sa_common.c +++ b/sa_common.c @@ -2005,16 +2005,19 @@ int parse_sa_P_opt(char *argv[], int *opt, unsigned int *flags, struct activity if (argv[++(*opt)]) { + if (!strcmp(argv[*opt], K_ALL)) { + /* + * Set bit for every processor. + * We still don't know if we are going to read stats + * from a file or not... + */ + memset(act[p]->bitmap->b_array, ~0, BITMAP_SIZE(act[p]->bitmap->b_size)); + (*opt)++; + return 0; + } + for (t = strtok(argv[*opt], ","); t; t = strtok(NULL, ",")) { - if (!strcmp(t, K_ALL)) { - /* - * Set bit for every processor. - * We still don't know if we are going to read stats - * from a file or not... - */ - memset(act[p]->bitmap->b_array, ~0, BITMAP_SIZE(act[p]->bitmap->b_size)); - } - else if (!strcmp(t, K_LOWERALL)) { + if (!strcmp(t, K_LOWERALL)) { /* Select CPU "all" (ie. global average CPU) */ act[p]->bitmap->b_array[0] |= 1; }