From 5f1465dda14ff329a352fbba699f7ac106c001e4 Mon Sep 17 00:00:00 2001 From: Michal Bloch Date: Wed, 21 Nov 2018 14:37:54 +0100 Subject: [PATCH] dlogctl: fix -s working as -c if without -t or -p Change-Id: Icf3dfee19d51a7312c4f392424774904622dd24e Signed-off-by: Michal Bloch --- src/logctl/logctl.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/logctl/logctl.c b/src/logctl/logctl.c index 2b13c51..678068e 100644 --- a/src/logctl/logctl.c +++ b/src/logctl/logctl.c @@ -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; -- 2.7.4