powerpc/mm/radix: add missing braces for single statement block
PATCH 1/1 powerpc/mm/radix: add missing braces for single statement block
In commit 7a22d6321c3d ("powerpc/mm/radix: Update command line parsing for disable_radix") an if statement was added for a possible empty body (prom_debug).
Fix the following warning, treated as error with W=1:
arch/powerpc/kernel/prom_init.c:656:46: error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]
--- arch/powerpc/kernel/prom_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/kernel/prom_init.c +2 -1
@@ -652,8 +652,9 @@ static void __init early_cmdline_parse(void) }else prom_radix_disable = true; } -if (prom_radix_disable) +if (prom_radix_disable) {prom_debug ("Radix disabled from cmdline\n" ); + } }#if defined(CONFIG_PPC_PSERIES ) || defined(CONFIG_PPC_POWERNV )
Signature · 1 line
2.11.0
Quoted 18 lines · Mathieu Malaterre
In commit
7a22d6321c3d("powerpc/mm/radix: Update command line parsing fordisable_radix") anifstatement was added for a possible empty body (prom_debug).Fix the following warning, treated as error with W=1:
arch/powerpc/kernel/prom_init.c:656:46: error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]Signed-off-by Mathieu Malaterre <[email protected]>--- arch/powerpc/kernel/prom_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/powerpc/kernel/prom_init.c +0
-0
arch/powerpc/kernel/prom_init.c static void __init early_cmdline_parse(void) · line 656
Quoted 6 lines
arch/powerpc/kernel/prom_init.c +1
-1@@ -652,8 +652,9 @@ static void __init early_cmdline_parse(void) }else prom_radix_disable = true; } -if (prom_radix_disable) +if (prom_radix_disable) {prom_debug ("Radix disabled from cmdline\n" );
Looks like the macro for #prom_debug() should be fixed instead.
Quoted 5 lines
arch/powerpc/kernel/prom_init.c +1
-0+ } }#if defined(CONFIG_PPC_PSERIES ) || defined(CONFIG_PPC_POWERNV )
Signature · 1 line
~Randy
On Sun, Apr 8, 2018 at 10:34 PM, Randy Dunlap <[email protected]> wrote= :
Quoted 2 lines · Mathieu Malaterre
Quoted 1 line
In commit
7a22d6321c3d("powerpc/mm/radix: Update command line parsing f=
or
Quoted 6 lines
Quoted 6 lines
disable_radix") anifstatement was added for a possible empty body (prom_debug).Fix the following warning, treated as error with W=3D1:
arch/powerpc/kernel/prom_init.c:656:46: error: suggest braces around e=
mpty body in an =E2=80=98if=E2=80=99 statement [-Werror=3Dempty-body]
Quoted 7 lines
arch/powerpc/kernel/prom_=
Quoted 7 lines
Signed-off-by Mathieu Malaterre <[email protected]>--- arch/powerpc/kernel/prom_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/powerpc/kernel/prom_= renamed from arch/powerpc/kernel/prom_init.c +0
-0
init.c
Quoted 4 lines
Quoted 4 lines
index
5ae153b97d0a..f0e802495530100644arch/powerpc/kernel/prom_init.c +0
-0@@ -652,8 +652,9 @@ static void __init early_cmdline_parse(void)
Quoted 8 lines
arch/powerpc/kernel/prom_init.c static void __init early_cmdline_parse(void) · line 656
Quoted 6 lines
arch/powerpc/kernel/prom_init.c +1
-1}else prom_radix_disable =3D true; } -if (prom_radix_disable) +if (prom_radix_disable) {prom_debug ("Radix disabled from cmdline\n" );Looks like the macro for #prom_debug() should be fixed instead.
Well if I try instead:
@@ -101,9 +101,9 @@ int of_workarounds;
} while (0)
#ifdef DEBUG_PROM
-#define prom_debug(x...) prom_printf(x)
+#define prom_debug(x...) do { prom_printf(x); } while (0)
#else
-#define prom_debug(x...)
+#define prom_debug(x...) do { } while (0)
#endif
the checkpatch script returns:
WARNING: Single statement macros should not use a do {} while (0) loop #33: FILE: arch/powerpc/kernel/prom_init.c:104:
+#define prom_debug(x...) do { prom_printf(x); } while (0)
So I suspect we cannot do much better than my original patch unfortunately.
Quoted 9 lines
arch/powerpc/kernel/prom_init.c static void __init early_cmdline_parse(void) · line 660
Quoted 5 lines
arch/powerpc/kernel/prom_init.c +1
-0+ } }#if defined(CONFIG_PPC_PSERIES ) || defined(CONFIG_PPC_POWERNV )--
~Randy
On Mon, Apr 23, 2018 at 9:31 PM, Mathieu Malaterre <[email protected]> wrote= :
Quoted 1 line
On Sun, Apr 8, 2018 at 10:34 PM, Randy Dunlap <[email protected]> wro=
te:
Quoted 2 lines
Quoted 2 lines · Mathieu Malaterre
Quoted 1 line
In commit
7a22d6321c3d("powerpc/mm/radix: Update command line parsing =
for
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
disable_radix") anifstatement was added for a possible empty body (prom_debug).Fix the following warning, treated as error with W=3D1:
arch/powerpc/kernel/prom_init.c:656:46: error: suggest braces around =
empty body in an =E2=80=98if=E2=80=99 statement [-Werror=3Dempty-body]
Quoted 7 lines
Quoted 7 lines
arch/powerpc/kernel/prom=
Quoted 7 lines
Signed-off-by Mathieu Malaterre <[email protected]>--- arch/powerpc/kernel/prom_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/powerpc/kernel/prom= renamed from arch/powerpc/kernel/prom_init.c +0
-0
_init.c
Quoted 29 lines
Quoted 4 lines
Quoted 4 lines
index
5ae153b97d0a..f0e802495530100644arch/powerpc/kernel/prom_init.c +0
-0@@ -652,8 +652,9 @@ static void __init early_cmdline_parse(void)Quoted 8 lines
arch/powerpc/kernel/prom_init.c static void __init early_cmdline_parse(void) · line 656
Quoted 6 lines
arch/powerpc/kernel/prom_init.c +1
-1}else prom_radix_disable =3D true; } -if (prom_radix_disable) +if (prom_radix_disable) {prom_debug ("Radix disabled from cmdline\n" );Looks like the macro for #prom_debug() should be fixed instead.
Well if I try instead:
(quoted diff) +2
-2@@ -101,9 +101,9 @@ int of_workarounds; } while (0) #ifdef DEBUG_PROM -#define prom_debug(x...) prom_printf(x) +#define prom_debug(x...) do { prom_printf(x); } while (0) #else -#define prom_debug(x...) +#define prom_debug(x...) do { } while (0) #endifthe checkpatch script returns:
Quoted 6 lines
WARNING: Single statement macros should not use a do {} while (0) loop #33: FILE:
arch/powerpc/kernel/prom_init.c:104:
+#defineprom_debug(x...)do {prom_printf(x); } while (0)So I suspect we cannot do much better than my original patch unfortunatel=
y.
Right, it seems I cannot read the correct line number for a warning. An updated patch is coming.
Quoted 9 lines
Quoted 9 lines
arch/powerpc/kernel/prom_init.c static void __init early_cmdline_parse(void) · line 660
Quoted 5 lines
arch/powerpc/kernel/prom_init.c +1
-0+ } }#if defined(CONFIG_PPC_PSERIES ) || defined(CONFIG_PPC_POWERNV )--
~Randy
PATCH v2 1/1 powerpc/mm/radix: use do/while(0) trick for single statement block
In reply to Mathieu MalaterreIn commit 7a22d6321c3d ("powerpc/mm/radix: Update command line parsing for disable_radix") an if statement was added for a possible empty body (prom_debug).
Fix the following warning, treated as error with W=1:
arch/powerpc/kernel/prom_init.c:656:46: error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]
---
v2: update macro directly
arch/powerpc/kernel/prom_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/prom_init.c +1 -1
@@ -103,7 +103,7 @@ int of_workarounds;#ifdef DEBUG_PROM #define prom_debug(x...) prom_printf(x)#else -#define prom_debug(x...) +#define prom_debug(x...) do { } while (0)#endif
Signature · 1 line
2.11.0
Re: [PATCH v2] powerpc/mm/radix: use do/while(0) trick for single statement block
Quoted 10 lines · Mathieu Malaterre
In commit
7a22d6321c3d("powerpc/mm/radix: Update command line parsing fordisable_radix") anifstatement was added for a possible empty body (prom_debug).Fix the following warning, treated as error with W=1:
arch/powerpc/kernel/prom_init.c:656:46: error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]Suggested-by Randy Dunlap <[email protected]>Signed-off-by Mathieu Malaterre <[email protected]>
Thanks.
Quoted 20 lines
---
v2: update macro directlyarch/powerpc/kernel/prom_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/powerpc/kernel/prom_init.c +1
-1@@ -103,7 +103,7 @@ int of_workarounds;#ifdef DEBUG_PROM #define prom_debug(x...) prom_printf(x)#else -#define prom_debug(x...) +#define prom_debug(x...) do { } while (0)#endif
Signature · 1 line
~Randy
Michael Ellerman
AppliedRe: [v2] powerpc/mm/radix: use do/while(0) trick for single statement block
In reply to Mathieu MalaterreQuoted 11 lines · Mathieu Malaterre
In commit
7a22d6321c3d("powerpc/mm/radix: Update command line parsing fordisable_radix") anifstatement was added for a possible empty body (prom_debug).Fix the following warning, treated as error with W=1:
arch/powerpc/kernel/prom_init.c:656:46: error: suggest braces around empty body in an ‘if’ statement [-Werror=empty-body]Suggested-by Randy Dunlap <[email protected]>Signed-off-by Mathieu Malaterre <[email protected]>Acked-by Randy Dunlap <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/85aa4b98419d74dd5cc914e0893498
cheers