[PATCH v3] powerpc/setup_64: fix -Wempty-body warnings

Qian Cai cai at lca.pw
Sat Jun 29 00:03:49 AEST 2019


At the beginning of setup_64.c, it has,

  #ifdef DEBUG
  #define DBG(fmt...) udbg_printf(fmt)
  #else
  #define DBG(fmt...)
  #endif

where DBG() could be compiled away, and generate warnings,

arch/powerpc/kernel/setup_64.c: In function 'initialize_cache_info':
arch/powerpc/kernel/setup_64.c:579:49: warning: suggest braces around
empty body in an 'if' statement [-Wempty-body]
    DBG("Argh, can't find dcache properties !\n");
                                                 ^
arch/powerpc/kernel/setup_64.c:582:49: warning: suggest braces around
empty body in an 'if' statement [-Wempty-body]
    DBG("Argh, can't find icache properties !\n");

Fix it by using the no_printk() macro, and make sure that format and
argument are always verified by the compiler.

Suggested-by: Tyrel Datwyler <tyreld at linux.vnet.ibm.com>
Suggested-by: Joe Perches <joe at perches.com>
Signed-off-by: Qian Cai <cai at lca.pw>
---

v3: Use no_printk() macro, and make sure that format and argument are always
    verified by the compiler using a more generic form ##__VA_ARGS__ per Joe.

v2: Fix it by using a NOP while loop per Tyrel.

 arch/powerpc/kernel/setup_64.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 44b4c432a273..cea933a43f0a 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -69,9 +69,9 @@
 #include "setup.h"
 
 #ifdef DEBUG
-#define DBG(fmt...) udbg_printf(fmt)
+#define DBG(fmt, ...) udbg_printf(fmt, ##__VA_ARGS__)
 #else
-#define DBG(fmt...)
+#define DBG(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
 #endif
 
 int spinning_secondaries;
-- 
1.8.3.1



More information about the Linuxppc-dev mailing list