Re: [PATCH] acpi: avoid -Wempty-body warnings

From: Rafael J. Wysocki
Date: Mon Mar 22 2021 - 09:28:20 EST


On Mon, Mar 22, 2021 at 11:59 AM Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
>
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> The acpi drivers produce a number of avoidable warnings for empty macros
> when building with 'make W=1':
>
> drivers/acpi/acpi_processor.c: In function 'acpi_processor_errata_piix4':
> drivers/acpi/acpi_processor.c:133:95: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 133 | "Bus master activity detection (BM-IDE) erratum enabled\n"));
> | ^
> drivers/acpi/acpi_processor.c:136:82: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 136 | "Type-F DMA livelock erratum (C3 disabled)\n"));
> | ^
> drivers/acpi/acpi_processor.c: In function 'acpi_processor_get_info':
> drivers/acpi/acpi_processor.c:251:77: error: suggest braces around empty body in an 'else' statement [-Werror=empty-body]
> 251 | "No bus mastering arbitration control\n"));
> | ^
> drivers/acpi/processor_pdc.c: In function 'acpi_processor_eval_pdc':
> drivers/acpi/processor_pdc.c:136:79: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 136 | "Could not evaluate _PDC, using legacy perf. control.\n"));
> | ^
>
> I tried making these call no_printk() instead, which would add proper
> format string checking, but that turned out to be a rather invasive
> change, so just shut up the warning by turning the macros into empty
> "do {} while (0)" statements.

This is part of ACPICA, so handing it to Erik and Bob.


> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---
> include/acpi/acoutput.h | 32 ++++++++++++++++----------------
> 1 file changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
> index 1538a6853822..b5484ef31f27 100644
> --- a/include/acpi/acoutput.h
> +++ b/include/acpi/acoutput.h
> @@ -433,23 +433,23 @@
> * This is the non-debug case -- make everything go away,
> * leaving no executable debug code!
> */
> -#define ACPI_DEBUG_PRINT(pl)
> -#define ACPI_DEBUG_PRINT_RAW(pl)
> -#define ACPI_DEBUG_EXEC(a)
> -#define ACPI_DEBUG_ONLY_MEMBERS(a)
> -#define ACPI_FUNCTION_NAME(a)
> -#define ACPI_FUNCTION_TRACE(a)
> -#define ACPI_FUNCTION_TRACE_PTR(a, b)
> -#define ACPI_FUNCTION_TRACE_U32(a, b)
> -#define ACPI_FUNCTION_TRACE_STR(a, b)
> -#define ACPI_FUNCTION_ENTRY()
> -#define ACPI_DUMP_STACK_ENTRY(a)
> -#define ACPI_DUMP_OPERANDS(a, b, c)
> -#define ACPI_DUMP_ENTRY(a, b)
> -#define ACPI_DUMP_PATHNAME(a, b, c, d)
> -#define ACPI_DUMP_BUFFER(a, b)
> +#define ACPI_DEBUG_PRINT(pl) do { } while (0)
> +#define ACPI_DEBUG_PRINT_RAW(pl) do { } while (0)
> +#define ACPI_DEBUG_EXEC(a) do { } while (0)
> +#define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while (0)
> +#define ACPI_FUNCTION_NAME(a) do { } while (0)
> +#define ACPI_FUNCTION_TRACE(a) do { } while (0)
> +#define ACPI_FUNCTION_TRACE_PTR(a, b) do { } while (0)
> +#define ACPI_FUNCTION_TRACE_U32(a, b) do { } while (0)
> +#define ACPI_FUNCTION_TRACE_STR(a, b) do { } while (0)
> +#define ACPI_FUNCTION_ENTRY() do { } while (0)
> +#define ACPI_DUMP_STACK_ENTRY(a) do { } while (0)
> +#define ACPI_DUMP_OPERANDS(a, b, c) do { } while (0)
> +#define ACPI_DUMP_ENTRY(a, b) do { } while (0)
> +#define ACPI_DUMP_PATHNAME(a, b, c, d) do { } while (0)
> +#define ACPI_DUMP_BUFFER(a, b) do { } while (0)
> #define ACPI_IS_DEBUG_ENABLED(level, component) 0
> -#define ACPI_TRACE_POINT(a, b, c, d)
> +#define ACPI_TRACE_POINT(a, b, c, d) do { } while (0)
>
> /* Return macros must have a return statement at the minimum */
>
> --
> 2.29.2
>