Re: [PATCH -next] kernel/trace: Replace printk and WARN_ON by WARN

From: Steven Rostedt
Date: Fri Aug 23 2024 - 08:29:25 EST


On Fri, 23 Aug 2024 17:18:03 +0800
Hongbo Li <lihongbo22@xxxxxxxxxx> wrote:

> Use WARN instead of printk + WARN_ON as reported from coccinelle:
> SUGGESTION: printk + WARN_ON can be just WARN
> Let's fix it and simplify the code.

Following the advice of robots causes the brain to stop functioning.

>
> Signed-off-by: Hongbo Li <lihongbo22@xxxxxxxxxx>
> ---
> 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 833e7d654325..5f385c55499f 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -2138,9 +2138,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");

You completely IGNORED and then REMOVED the comment!!!!

Notice that it's not even a KERN_WARN, it's a KERN_CONT.

BIG NACK!

-- Steve

> return -1;
> }
> /* Only reset on passing, to avoid touching corrupted buffers */