From: Philippe Proulx Date: Wed, 24 Jul 2019 14:25:17 +0000 (-0400) Subject: cli: remove the global volatile `interrupted` variable X-Git-Url: https://git.efficios.com/?a=commitdiff_plain;h=aede8fc9160e48cc3bc6803c8c337e1a5b6a364c;p=babeltrace.git cli: remove the global volatile `interrupted` variable We can use the global interrupter's state instead, and we don't need to check the interruption status before calling bt_query_executor_query() and bt_graph_run() as both functions check their interruption state initially. Signed-off-by: Philippe Proulx Change-Id: I3818843c44b016cf2b872d879b461eae52730e6b Reviewed-on: https://review.lttng.org/c/babeltrace/+/1758 Tested-by: jenkins --- diff --git a/src/cli/babeltrace2.c b/src/cli/babeltrace2.c index 9699b0c3..a0c6df11 100644 --- a/src/cli/babeltrace2.c +++ b/src/cli/babeltrace2.c @@ -57,7 +57,6 @@ static const char* log_level_env_var_names[] = { /* Application's interrupter (owned by this) */ static bt_interrupter *the_interrupter; -static volatile bool interrupted = false; #ifdef __MINGW32__ @@ -69,7 +68,6 @@ BOOL WINAPI signal_handler(DWORD signal) { bt_interrupter_set(the_interrupter); } - interrupted = true; return TRUE; } @@ -93,8 +91,6 @@ void signal_handler(int signum) if (the_interrupter) { bt_interrupter_set(the_interrupter); } - - interrupted = true; } static @@ -135,16 +131,6 @@ int query(struct bt_config *cfg, const bt_component_class *comp_cls, bt_query_executor_add_interrupter(query_exec, the_interrupter); - if (interrupted) { - BT_CLI_LOGW_APPEND_CAUSE( - "Interrupted by user before executing the query: " - "comp-cls-addr=%p, comp-cls-name=\"%s\", " - "query-obj=\"%s\"", comp_cls, - bt_component_class_get_name(comp_cls), obj); - *fail_reason = "interrupted by user"; - goto error; - } - while (true) { query_status = bt_query_executor_query( query_exec, comp_cls, obj, params, @@ -2311,7 +2297,7 @@ int cmd_run(struct bt_config *cfg) goto error; } - if (interrupted) { + if (bt_interrupter_is_set(the_interrupter)) { BT_CLI_LOGW_APPEND_CAUSE( "Interrupted by user before creating components."); goto error; @@ -2325,7 +2311,7 @@ int cmd_run(struct bt_config *cfg) goto error; } - if (interrupted) { + if (bt_interrupter_is_set(the_interrupter)) { BT_CLI_LOGW_APPEND_CAUSE( "Interrupted by user before connecting components."); goto error; @@ -2340,12 +2326,6 @@ int cmd_run(struct bt_config *cfg) goto error; } - if (interrupted) { - BT_CLI_LOGW_APPEND_CAUSE( - "Interrupted by user before running the graph."); - goto error; - } - BT_LOGI_STR("Running the graph."); /* Run the graph */