dlogctl: fix -s working as -c if without -t or -p 36/193536/1 accepted/tizen/unified/20181123.063254 submit/tizen/20181122.055216
authorMichal Bloch <m.bloch@samsung.com>
Wed, 21 Nov 2018 13:37:54 +0000 (14:37 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Wed, 21 Nov 2018 13:37:58 +0000 (14:37 +0100)
Change-Id: Icf3dfee19d51a7312c4f392424774904622dd24e
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/logctl/logctl.c

index 2b13c51..678068e 100644 (file)
@@ -93,14 +93,10 @@ bool parse_options(int argc, const char **argv, struct parsed_params *params, in
                        SET_ACTION(ACTION_GET);
                        break;
                case 'c':
-                       if (params->value) // -s already used
-                               goto failure;
-                       SET_ACTION(ACTION_SET);
+                       SET_ACTION(ACTION_CLEAR);
                        params->value = NULL;
                        break;
                case 's': {
-                       if (params->action == ACTION_SET && !params->value) // -c already used
-                               goto failure;
                        const int value_num = atoi(optarg);
                        if (strcmp(optarg, "allow") && strcmp(optarg, "deny") && (value_num <= 0 || value_num >= __LOG_LIMITER_LIMIT_MAX))
                                goto failure;
@@ -133,17 +129,18 @@ bool parse_options(int argc, const char **argv, struct parsed_params *params, in
                goto print_help;
        }
 
-       if (use_global_action) {
-               switch (params->action) {
-               case ACTION_GET:
+       switch (params->action) {
+       case ACTION_GET:
+               if (use_global_action)
                        params->action = ACTION_DUMP;
-                       break;
-               case ACTION_SET:
-                       params->action = ACTION_CLEAR;
-                       break;
-               default:
-                       break;
-               }
+               break;
+       case ACTION_CLEAR:
+               if (!use_global_action)
+                       params->action = ACTION_SET;
+               break;
+
+       default:
+               break;
        }
 
        return true;