From: Guo Zhengkui <guozhengkui@vivo.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org (open list)
Cc: zhengkui_guo@outlook.com, Guo Zhengkui <guozhengkui@vivo.com>
Subject: [PATCH v2] trace: use WARN instead of printk and WARN_ON
Date: Sun, 24 Apr 2022 21:19:32 +0800 [thread overview]
Message-ID: <20220424131932.3606-1-guozhengkui@vivo.com> (raw)
In-Reply-To: <20211207091843.0765fa3f@gandalf.local.home>
Use `WARN(cond, ...)` instead of `if (cond)` + `printk(...)` +
`WARN_ON(1)`.
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Guo Zhengkui <guozhengkui@vivo.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
next prev parent reply other threads:[~2022-04-24 13:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 12:55 [PATCH] " Qing Wang
2021-12-07 14:18 ` Steven Rostedt
2022-04-24 12:09 ` [PATCH v2] " Guo Zhengkui
2022-04-24 13:19 ` Guo Zhengkui [this message]
[not found] ` <AHoASQC9E8*4-sq3w2XY7ao3.9.1638886730256.Hmail.wangqing@vivo.com.@PDIwMjExMjA3MDkxODQzLjA3NjVmYTNmQGdhbmRhbGYubG9jYWwuaG9tZT4=>
2021-12-08 8:11 ` [PATCH] " 王擎
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220424131932.3606-1-guozhengkui@vivo.com \
--to=guozhengkui@vivo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=zhengkui_guo@outlook.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®