2020-03-27 21:25:37

by Jules Irenge

[permalink] [raw]
Subject: [PATCH 10/10] trace: Replace printk and WARN_ON with WARN

Coccinelle suggests replacing printk and WARN_ON with WARN

SUGGESTION: printk + WARN_ON can be just WARN.
Signed-off-by: Jules Irenge <[email protected]>
---
kernel/trace/trace.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 6b11e4e2150c..1fe31272ea73 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1799,9 +1799,7 @@ static int run_tracer_selftest(struct tracer *type)
/* the test is responsible for resetting too */
tr->current_trace = saved_tracer;
if (ret) {
- printk(KERN_CONT "FAILED!\n");
- /* Add the warning after printing 'FAILED' */
- WARN_ON(1);
+ WARN(1, "FAILED!\n");
return -1;
}
/* Only reset on passing, to avoid touching corrupted buffers */
--
2.25.1


2020-03-27 22:53:25

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 10/10] trace: Replace printk and WARN_ON with WARN

On Fri, 27 Mar 2020 21:23:57 +0000
Jules Irenge <[email protected]> wrote:

> Coccinelle suggests replacing printk and WARN_ON with WARN
>
> SUGGESTION: printk + WARN_ON can be just WARN.
> Signed-off-by: Jules Irenge <[email protected]>
> ---
> kernel/trace/trace.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 6b11e4e2150c..1fe31272ea73 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -1799,9 +1799,7 @@ static int run_tracer_selftest(struct tracer *type)
> /* the test is responsible for resetting too */
> tr->current_trace = saved_tracer;
> if (ret) {
> - printk(KERN_CONT "FAILED!\n");
> - /* Add the warning after printing 'FAILED' */

NACK! Did you not read the above comment. The FAILED goes with another
print and should NOT be part of the WARN_ON.

-- Steve

> - WARN_ON(1);
> + WARN(1, "FAILED!\n");
> return -1;
> }
> /* Only reset on passing, to avoid touching corrupted buffers */

2020-03-28 12:01:55

by Jules Irenge

[permalink] [raw]
Subject: Re: [PATCH 10/10] trace: Replace printk and WARN_ON with WARN



On Fri, 27 Mar 2020, Steven Rostedt wrote:

> On Fri, 27 Mar 2020 21:23:57 +0000
> Jules Irenge <[email protected]> wrote:
>
> > Coccinelle suggests replacing printk and WARN_ON with WARN
> >
> > SUGGESTION: printk + WARN_ON can be just WARN.
> > Signed-off-by: Jules Irenge <[email protected]>
> > ---
> > kernel/trace/trace.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> > index 6b11e4e2150c..1fe31272ea73 100644
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -1799,9 +1799,7 @@ static int run_tracer_selftest(struct tracer *type)
> > /* the test is responsible for resetting too */
> > tr->current_trace = saved_tracer;
> > if (ret) {
> > - printk(KERN_CONT "FAILED!\n");
> > - /* Add the warning after printing 'FAILED' */
>
> NACK! Did you not read the above comment. The FAILED goes with another
> print and should NOT be part of the WARN_ON.
>
> -- Steve
>
> > - WARN_ON(1);
> > + WARN(1, "FAILED!\n");
> > return -1;
> > }
> > /* Only reset on passing, to avoid touching corrupted buffers */
>
>
Thanks for the feedback, I will be more careful next time.
Kind regards,
Jules