Skip to contentSkip to conversation

acpi: avoid -Wempty-body warnings

PATCH In review Arnd Bergmann 2 participants 2 messages Mar 22, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi: avoid -Wempty-body warnings

From: Arnd Bergmann <[email protected]>

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.

---
 include/acpi/acoutput.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
include/acpi/acoutput.h +16 -16
index 1538a6853822..b5484ef31f27 100644
@@ -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 */
 
Signature · 1 line
2.29.2
#1 lore raw
Quoted 22 lines · Arnd Bergmann

From: Arnd Bergmann <arnd(a)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"));
| ^

Quoted 4 lines

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.

Quoted 52 lines
Signed-off-by Arnd Bergmann <arnd(a)arndb.de>
---
 include/acpi/acoutput.h | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
include/acpi/acoutput.h +16 -17
index 1538a6853822..b5484ef31f27 100644
@@ -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