]> granicus.if.org Git - sysstat/commitdiff
sar: Rework option -P parsing
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 20 Nov 2016 09:31:41 +0000 (10:31 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sun, 20 Nov 2016 09:31:41 +0000 (10:31 +0100)
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 <sysstat@users.noreply.github.com>
sa_common.c

index 057042924752ad81de76b6ef289c0efbaf9db0d7..9a2c4e7035940eacbe8a8f8e17d85a01c05e9367 100644 (file)
@@ -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;
                        }