From 607cfca4f089ece33dcbaeef207dd82c834dd265 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sun, 20 Nov 2016 10:31:41 +0100 Subject: [PATCH] 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 --- sa_common.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) 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; } -- 2.40.0