[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220424120954.3368-1-guozhengkui@vivo.com>
Date: Sun, 24 Apr 2022 20:09:54 +0800
From: Guo Zhengkui <guozhengkui@...o.com>
To: Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>,
linux-kernel@...r.kernel.org (open list)
Cc: zhengkui_guo@...look.com, Guo Zhengkui <guozhengkui@...o.com>,
Qing Wang <wangqing@...o.com>
Subject: [PATCH v2] trace: use WARN instead of printk and WARN_ON
Use `WARN(cond, ...)` instead of `if (cond)` + `printk(...)` +
`WARN_ON(1)`.
Signed-off-by: Steven Rostedt <rostedt@...dmis.org>
Signed-off-by: Qing Wang <wangqing@...o.com>
Signed-off-by: Guo Zhengkui <guozhengkui@...o.com>
---
v1 -> v2: Put WARN in the condition according to Steven's suggestion.
kernel/trace/trace_output.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 8aa493d25c73..d89e3f7e26eb 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -778,9 +778,8 @@ 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);
+ } else if (WARN(event->type > __TRACE_LAST_TYPE,
+ "Need to add type to trace.h")) {
goto out;
} else {
/* Is this event already used */
@@ -1571,13 +1570,8 @@ __init static int init_events(void)
for (i = 0; events[i]; i++) {
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);
- }
+ WARN_ONCE(!ret, "event %d failed to register", event->type);
}
return 0;
--
2.20.1
Powered by blists - more mailing lists