lkml.org 
[lkml]   [2021]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] trace: use WARN instead of printk and WARN_ON
Date

>> From: Wang Qing <wangqing@vivo.com>
>>
>> Simply use WARN instead of printk(KERN_WARNING, ...) and WARN_ON.
>>
>> Signed-off-by: Wang Qing <wangqing@vivo.com>
>> ---
>>  kernel/trace/trace_output.c | 11 ++++-------
>>  1 file changed, 4 insertions(+), 7 deletions(-)
>>
>> diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
>> index 3547e71..e0348ec
>> --- a/kernel/trace/trace_output.c
>> +++ b/kernel/trace/trace_output.c
>> @@ -775,8 +775,7 @@ int register_trace_event(struct trace_event *event)
>>                list_add_tail(&event->list, list);
>> 
>>        } else if (event->type > __TRACE_LAST_TYPE) {
>> -             printk(KERN_WARNING "Need to add type to trace.h\n");
>> -             WARN_ON(1);
>> +             WARN(1, "Need to add type to trace.h\n");
>
>If you are going to fix this, then please fix it properly.

Is there any problem with this modification?

>
>       } else if (WARN(event->type > __TRACE_LAST_TYPE,
>>                       "Need to add type to trace.h")) {
>
>>                goto out;
>>        } else {
>>                /* Is this event already used */
>> @@ -1569,11 +1568,9 @@ __init static int init_events(void)
>>                event = events[i];
>> 
>>                ret = register_trace_event(event);
>> -             if (!ret) {
>> -                     printk(KERN_WARNING "event %d failed to register\n",
>> -                            event->type);
>> -                     WARN_ON_ONCE(1);
>> -             }
>> +             if (!ret)
>> +                     WARN_ONCE(1, "event %d failed to register\n",
>> +                               event->type);
>
>And this should just turn into:
>
>                WARN_ONCE(!ret, "event %d failed to register", event->type);

Yes,this should be right.

Thanks,
Qing

>-- Steve
>
>
>>        }
>> 
>>        return 0;
\
 
 \ /
  Last update: 2021-12-08 09:13    [W:0.104 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site