diff mbox series

powerpc/setup_64: fix -Wempty-body warnings

Message ID 1559765875-6328-1-git-send-email-cai@lca.pw (mailing list archive)
State Superseded, archived
Headers show
Series powerpc/setup_64: fix -Wempty-body warnings | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (a3bf9fbdad600b1e4335dd90979f8d6072e4f602)
snowpatch_ozlabs/build-ppc64le success Build succeeded
snowpatch_ozlabs/build-ppc64be success Build succeeded
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch warning total: 0 errors, 2 warnings, 0 checks, 17 lines checked

Commit Message

Qian Cai June 5, 2019, 8:17 p.m. UTC
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");

Signed-off-by: Qian Cai <cai@lca.pw>
---
 arch/powerpc/kernel/setup_64.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Tyrel Datwyler June 5, 2019, 8:33 p.m. UTC | #1
On 06/05/2019 01:17 PM, Qian Cai wrote:
> At the beginning of setup_64.c, it has,
> 
>   #ifdef DEBUG
>   #define DBG(fmt...) udbg_printf(fmt)
>   #else
>   #define DBG(fmt...)
>   #endif

Simpler solution is just to define the debug in the else clause as such:

#define DBG(fmt...) do { } while(0)

-Tyrel

> 
> 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");
> 
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>  arch/powerpc/kernel/setup_64.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
> index 44b4c432a273..23758834324f 100644
> --- a/arch/powerpc/kernel/setup_64.c
> +++ b/arch/powerpc/kernel/setup_64.c
> @@ -575,12 +575,13 @@ void __init initialize_cache_info(void)
>  	 * d-cache and i-cache sizes... -Peter
>  	 */
>  	if (cpu) {
> -		if (!parse_cache_info(cpu, false, &ppc64_caches.l1d))
> +		/* Add an extra brace to silence -Wempty-body warnings. */
> +		if (!parse_cache_info(cpu, false, &ppc64_caches.l1d)) {
>  			DBG("Argh, can't find dcache properties !\n");
> -
> -		if (!parse_cache_info(cpu, true, &ppc64_caches.l1i))
> +		}
> +		if (!parse_cache_info(cpu, true, &ppc64_caches.l1i)) {
>  			DBG("Argh, can't find icache properties !\n");
> -
> +		}
>  		/*
>  		 * Try to find the L2 and L3 if any. Assume they are
>  		 * unified and use the D-side properties.
>
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 44b4c432a273..23758834324f 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -575,12 +575,13 @@  void __init initialize_cache_info(void)
 	 * d-cache and i-cache sizes... -Peter
 	 */
 	if (cpu) {
-		if (!parse_cache_info(cpu, false, &ppc64_caches.l1d))
+		/* Add an extra brace to silence -Wempty-body warnings. */
+		if (!parse_cache_info(cpu, false, &ppc64_caches.l1d)) {
 			DBG("Argh, can't find dcache properties !\n");
-
-		if (!parse_cache_info(cpu, true, &ppc64_caches.l1i))
+		}
+		if (!parse_cache_info(cpu, true, &ppc64_caches.l1i)) {
 			DBG("Argh, can't find icache properties !\n");
-
+		}
 		/*
 		 * Try to find the L2 and L3 if any. Assume they are
 		 * unified and use the D-side properties.