From: Erik Schmauss Date: Mon, 5 Nov 2018 17:43:51 +0000 (-0800) Subject: ACPICA: Debugger: refactor to fix unused variable warning X-Git-Tag: v5.0-rc1~177^2~2^2~10^2~4 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=c647eb98b0852367752ab22dbf97e9ff146f0c21;p=linux.git ACPICA: Debugger: refactor to fix unused variable warning When building ACPICA in the Linux kernel with Clang with ACPI_DISASSEMBLER not defined, we get a the following warning on variable display_op: warning: variable 'display_op' set but not used [-Wunused-but-set-variable] Fix this by refactoring display_op and parent_op code in a separate function. Suggested-by: Colin Ian King Signed-off-by: Erik Schmauss Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/acpi/acpica/dbxface.c b/drivers/acpi/acpica/dbxface.c index f2526726daf6..3eb45ea93e5e 100644 --- a/drivers/acpi/acpica/dbxface.c +++ b/drivers/acpi/acpica/dbxface.c @@ -24,6 +24,13 @@ acpi_db_start_command(struct acpi_walk_state *walk_state, void acpi_db_method_end(struct acpi_walk_state *walk_state); #endif +#ifdef ACPI_DISASSEMBLER +static union acpi_parse_object *acpi_db_get_display_op(struct acpi_walk_state + *walk_state, + union acpi_parse_object + *op); +#endif + /******************************************************************************* * * FUNCTION: acpi_db_start_command @@ -113,6 +120,70 @@ void acpi_db_signal_break_point(struct acpi_walk_state *walk_state) acpi_os_printf("**break** Executed AML BreakPoint opcode\n"); } +#ifdef ACPI_DISASSEMBLER +/******************************************************************************* + * + * FUNCTION: acpi_db_get_display_op + * + * PARAMETERS: walk_state - Current walk + * op - Current executing op (from aml interpreter) + * + * RETURN: Opcode to display + * + * DESCRIPTION: Find the opcode to display during single stepping + * + ******************************************************************************/ + +static union acpi_parse_object *acpi_db_get_display_op(struct acpi_walk_state + *walk_state, + union acpi_parse_object + *op) +{ + union acpi_parse_object *display_op; + union acpi_parse_object *parent_op; + + display_op = op; + parent_op = op->common.parent; + if (parent_op) { + if ((walk_state->control_state) && + (walk_state->control_state->common.state == + ACPI_CONTROL_PREDICATE_EXECUTING)) { + /* + * We are executing the predicate of an IF or WHILE statement + * Search upwards for the containing IF or WHILE so that the + * entire predicate can be displayed. + */ + while (parent_op) { + if ((parent_op->common.aml_opcode == AML_IF_OP) + || (parent_op->common.aml_opcode == + AML_WHILE_OP)) { + display_op = parent_op; + break; + } + parent_op = parent_op->common.parent; + } + } else { + while (parent_op) { + if ((parent_op->common.aml_opcode == AML_IF_OP) + || (parent_op->common.aml_opcode == + AML_ELSE_OP) + || (parent_op->common.aml_opcode == + AML_SCOPE_OP) + || (parent_op->common.aml_opcode == + AML_METHOD_OP) + || (parent_op->common.aml_opcode == + AML_WHILE_OP)) { + break; + } + display_op = parent_op; + parent_op = parent_op->common.parent; + } + } + } + return display_op; +} +#endif + /******************************************************************************* * * FUNCTION: acpi_db_single_step @@ -134,8 +205,6 @@ acpi_db_single_step(struct acpi_walk_state *walk_state, union acpi_parse_object *next; acpi_status status = AE_OK; u32 original_debug_level; - union acpi_parse_object *display_op; - union acpi_parse_object *parent_op; u32 aml_offset; ACPI_FUNCTION_ENTRY(); @@ -222,51 +291,12 @@ acpi_db_single_step(struct acpi_walk_state *walk_state, next = op->common.next; op->common.next = NULL; - display_op = op; - parent_op = op->common.parent; - if (parent_op) { - if ((walk_state->control_state) && - (walk_state->control_state->common.state == - ACPI_CONTROL_PREDICATE_EXECUTING)) { - /* - * We are executing the predicate of an IF or WHILE statement - * Search upwards for the containing IF or WHILE so that the - * entire predicate can be displayed. - */ - while (parent_op) { - if ((parent_op->common.aml_opcode == - AML_IF_OP) - || (parent_op->common.aml_opcode == - AML_WHILE_OP)) { - display_op = parent_op; - break; - } - parent_op = parent_op->common.parent; - } - } else { - while (parent_op) { - if ((parent_op->common.aml_opcode == - AML_IF_OP) - || (parent_op->common.aml_opcode == - AML_ELSE_OP) - || (parent_op->common.aml_opcode == - AML_SCOPE_OP) - || (parent_op->common.aml_opcode == - AML_METHOD_OP) - || (parent_op->common.aml_opcode == - AML_WHILE_OP)) { - break; - } - display_op = parent_op; - parent_op = parent_op->common.parent; - } - } - } - /* Now we can disassemble and display it */ #ifdef ACPI_DISASSEMBLER - acpi_dm_disassemble(walk_state, display_op, ACPI_UINT32_MAX); + acpi_dm_disassemble(walk_state, + acpi_db_get_display_op(walk_state, op), + ACPI_UINT32_MAX); #else /* * The AML Disassembler is not configured - at least we can