linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] acpi: avoid -Wempty-body warnings
@ 2021-03-22 10:58 Arnd Bergmann
  2021-03-22 13:27 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-03-22 10:58 UTC (permalink / raw)
  To: Robert Moore, Erik Kaneda, Rafael J. Wysocki, Len Brown
  Cc: Arnd Bergmann, linux-acpi, devel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] acpi: avoid -Wempty-body warnings
  2021-03-22 10:58 [PATCH] acpi: avoid -Wempty-body warnings Arnd Bergmann
@ 2021-03-22 13:27 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2021-03-22 13:27 UTC (permalink / raw)
  To: Arnd Bergmann, Erik Kaneda, Robert Moore
  Cc: Rafael J. Wysocki, Len Brown, Arnd Bergmann,
	ACPI Devel Maling List,
	open list:ACPI COMPONENT ARCHITECTURE (ACPICA),
	Linux Kernel Mailing List

On Mon, Mar 22, 2021 at 11:59 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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@arndb.de>
> ---
>  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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-22 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-22 10:58 [PATCH] acpi: avoid -Wempty-body warnings Arnd Bergmann
2021-03-22 13:27 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).