linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/interrupt: Put braces around empty body in an 'if' statement
@ 2022-06-19  3:11 Souptick Joarder
  2022-06-19  5:42 ` Randy Dunlap
  2022-06-19  6:40 ` Christophe Leroy
  0 siblings, 2 replies; 4+ messages in thread
From: Souptick Joarder @ 2022-06-19  3:11 UTC (permalink / raw)
  To: mpe, benh, paulus, npiggin, christophe.leroy, tglx, mark.rutland
  Cc: Kernel test robot, linuxppc-dev, linux-kernel, Souptick Joarder (HPE)

From: "Souptick Joarder (HPE)" <jrdr.linux@gmail.com>

Kernel test robot throws warning ->

arch/powerpc/kernel/interrupt.c:
In function 'interrupt_exit_kernel_prepare':

>> arch/powerpc/kernel/interrupt.c:542:55: warning: suggest
braces around empty body in an 'if' statement [-Wempty-body]
     542 |                 CT_WARN_ON(ct_state() == CONTEXT_USER);

Fix it by adding braces.

Reported-by: Kernel test robot <lkp@intel.com>
Signed-off-by: Souptick Joarder (HPE) <jrdr.linux@gmail.com>
---
 arch/powerpc/kernel/interrupt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index 784ea3289c84..b8a918bab48f 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -538,8 +538,9 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
 	 * CT_WARN_ON comes here via program_check_exception,
 	 * so avoid recursion.
 	 */
-	if (TRAP(regs) != INTERRUPT_PROGRAM)
+	if (TRAP(regs) != INTERRUPT_PROGRAM) {
 		CT_WARN_ON(ct_state() == CONTEXT_USER);
+	}
 
 	kuap = kuap_get_and_assert_locked();
 
-- 
2.25.1


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

* Re: [PATCH] powerpc/interrupt: Put braces around empty body in an 'if' statement
  2022-06-19  3:11 [PATCH] powerpc/interrupt: Put braces around empty body in an 'if' statement Souptick Joarder
@ 2022-06-19  5:42 ` Randy Dunlap
  2022-06-19  6:43   ` Souptick Joarder
  2022-06-19  6:40 ` Christophe Leroy
  1 sibling, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2022-06-19  5:42 UTC (permalink / raw)
  To: Souptick Joarder, mpe, benh, paulus, npiggin, christophe.leroy,
	tglx, mark.rutland
  Cc: Frederic Weisbecker, linuxppc-dev, linux-kernel, Kernel test robot



On 6/18/22 20:11, Souptick Joarder wrote:
> From: "Souptick Joarder (HPE)" <jrdr.linux@gmail.com>
> 
> Kernel test robot throws warning ->
> 
> arch/powerpc/kernel/interrupt.c:
> In function 'interrupt_exit_kernel_prepare':
> 
>>> arch/powerpc/kernel/interrupt.c:542:55: warning: suggest
> braces around empty body in an 'if' statement [-Wempty-body]
>      542 |                 CT_WARN_ON(ct_state() == CONTEXT_USER);

That must be when CONFIG_CONTEXT_TRACKING_USER is not set/enabled.
Can you confirm that?

Then the preferable fix would be in <linux/context_tracking.h>:

change
#define CT_WARN_ON(cond)

to either an empty do-while loop or a static inline function.

(adding Frederic to Cc:)

> 
> Fix it by adding braces.
> 
> Reported-by: Kernel test robot <lkp@intel.com>
> Signed-off-by: Souptick Joarder (HPE) <jrdr.linux@gmail.com>
> ---
>  arch/powerpc/kernel/interrupt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
> index 784ea3289c84..b8a918bab48f 100644
> --- a/arch/powerpc/kernel/interrupt.c
> +++ b/arch/powerpc/kernel/interrupt.c
> @@ -538,8 +538,9 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
>  	 * CT_WARN_ON comes here via program_check_exception,
>  	 * so avoid recursion.
>  	 */
> -	if (TRAP(regs) != INTERRUPT_PROGRAM)
> +	if (TRAP(regs) != INTERRUPT_PROGRAM) {
>  		CT_WARN_ON(ct_state() == CONTEXT_USER);
> +	}
>  
>  	kuap = kuap_get_and_assert_locked();
>  

-- 
~Randy

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

* Re: [PATCH] powerpc/interrupt: Put braces around empty body in an 'if' statement
  2022-06-19  3:11 [PATCH] powerpc/interrupt: Put braces around empty body in an 'if' statement Souptick Joarder
  2022-06-19  5:42 ` Randy Dunlap
@ 2022-06-19  6:40 ` Christophe Leroy
  1 sibling, 0 replies; 4+ messages in thread
From: Christophe Leroy @ 2022-06-19  6:40 UTC (permalink / raw)
  To: Souptick Joarder, mpe, benh, paulus, npiggin, tglx, mark.rutland
  Cc: linuxppc-dev, linux-kernel, Kernel test robot



Le 19/06/2022 à 05:11, Souptick Joarder a écrit :
> From: "Souptick Joarder (HPE)" <jrdr.linux@gmail.com>
> 
> Kernel test robot throws warning ->
> 
> arch/powerpc/kernel/interrupt.c:
> In function 'interrupt_exit_kernel_prepare':
> 
>>> arch/powerpc/kernel/interrupt.c:542:55: warning: suggest
> braces around empty body in an 'if' statement [-Wempty-body]
>       542 |                 CT_WARN_ON(ct_state() == CONTEXT_USER);
> 
> Fix it by adding braces.

There must be no braces for single 'if' statement , see 
https://docs.kernel.org/process/coding-style.html#placing-braces-and-spaces

The problem is likely that CT_WARN_ON() is empty in some CONFIGs.
You have to fix it, for instance by changing it to a "do { } while (0)"

> 
> Reported-by: Kernel test robot <lkp@intel.com>
> Signed-off-by: Souptick Joarder (HPE) <jrdr.linux@gmail.com>
> ---
>   arch/powerpc/kernel/interrupt.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
> index 784ea3289c84..b8a918bab48f 100644
> --- a/arch/powerpc/kernel/interrupt.c
> +++ b/arch/powerpc/kernel/interrupt.c
> @@ -538,8 +538,9 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
>           * CT_WARN_ON comes here via program_check_exception,
>           * so avoid recursion.
>           */
> -       if (TRAP(regs) != INTERRUPT_PROGRAM)
> +       if (TRAP(regs) != INTERRUPT_PROGRAM) {
>                  CT_WARN_ON(ct_state() == CONTEXT_USER);
> +       }
> 
>          kuap = kuap_get_and_assert_locked();
> 
> --
> 2.25.1
> 

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

* Re: [PATCH] powerpc/interrupt: Put braces around empty body in an 'if' statement
  2022-06-19  5:42 ` Randy Dunlap
@ 2022-06-19  6:43   ` Souptick Joarder
  0 siblings, 0 replies; 4+ messages in thread
From: Souptick Joarder @ 2022-06-19  6:43 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Mark Rutland, Kernel test robot, Frederic Weisbecker,
	linux-kernel, Paul Mackerras, Nick Piggin, Thomas Gleixner,
	linuxppc-dev

On Sun, Jun 19, 2022 at 11:13 AM Randy Dunlap <rdunlap@infradead.org> wrote:
>
>
>
> On 6/18/22 20:11, Souptick Joarder wrote:
> > From: "Souptick Joarder (HPE)" <jrdr.linux@gmail.com>
> >
> > Kernel test robot throws warning ->
> >
> > arch/powerpc/kernel/interrupt.c:
> > In function 'interrupt_exit_kernel_prepare':
> >
> >>> arch/powerpc/kernel/interrupt.c:542:55: warning: suggest
> > braces around empty body in an 'if' statement [-Wempty-body]
> >      542 |                 CT_WARN_ON(ct_state() == CONTEXT_USER);
>
> That must be when CONFIG_CONTEXT_TRACKING_USER is not set/enabled.
> Can you confirm that?

Yes, CONFIG_CONTEXT_TRACKING_USER is not set.
>
> Then the preferable fix would be in <linux/context_tracking.h>:
>
> change
> #define CT_WARN_ON(cond)
>
> to either an empty do-while loop or a static inline function.
>
> (adding Frederic to Cc:)
>
> >
> > Fix it by adding braces.
> >
> > Reported-by: Kernel test robot <lkp@intel.com>
> > Signed-off-by: Souptick Joarder (HPE) <jrdr.linux@gmail.com>
> > ---
> >  arch/powerpc/kernel/interrupt.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
> > index 784ea3289c84..b8a918bab48f 100644
> > --- a/arch/powerpc/kernel/interrupt.c
> > +++ b/arch/powerpc/kernel/interrupt.c
> > @@ -538,8 +538,9 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)
> >        * CT_WARN_ON comes here via program_check_exception,
> >        * so avoid recursion.
> >        */
> > -     if (TRAP(regs) != INTERRUPT_PROGRAM)
> > +     if (TRAP(regs) != INTERRUPT_PROGRAM) {
> >               CT_WARN_ON(ct_state() == CONTEXT_USER);
> > +     }
> >
> >       kuap = kuap_get_and_assert_locked();
> >
>
> --
> ~Randy

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

end of thread, other threads:[~2022-06-19  6:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-19  3:11 [PATCH] powerpc/interrupt: Put braces around empty body in an 'if' statement Souptick Joarder
2022-06-19  5:42 ` Randy Dunlap
2022-06-19  6:43   ` Souptick Joarder
2022-06-19  6:40 ` Christophe Leroy

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).