From: Jani Nikula <jani.nikula@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Greg KH <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Cc: jani.nikula@intel.com
Subject: [RFC 1/4] kernel/panic: return early from print_tainted() when not tainted
Date: Mon, 25 Mar 2024 17:36:32 +0200 [thread overview]
Message-ID: <2adfb5b76982d65d83077c8c5b269dbd8a63864a.1711380724.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1711380724.git.jani.nikula@intel.com>
Reduce indent to make follow-up changes slightly easier on the eyes.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
kernel/panic.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/kernel/panic.c b/kernel/panic.c
index 628673ddf1c9..b6d4d1da1eaa 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -509,22 +509,23 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = {
const char *print_tainted(void)
{
static char buf[TAINT_FLAGS_COUNT + sizeof("Tainted: ")];
+ char *s;
+ int i;
BUILD_BUG_ON(ARRAY_SIZE(taint_flags) != TAINT_FLAGS_COUNT);
- if (tainted_mask) {
- char *s;
- int i;
-
- s = buf + sprintf(buf, "Tainted: ");
- for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
- const struct taint_flag *t = &taint_flags[i];
- *s++ = test_bit(i, &tainted_mask) ?
- t->c_true : t->c_false;
- }
- *s = 0;
- } else
+ if (!tainted_mask) {
snprintf(buf, sizeof(buf), "Not tainted");
+ return buf;
+ }
+
+ s = buf + sprintf(buf, "Tainted: ");
+ for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
+ const struct taint_flag *t = &taint_flags[i];
+ *s++ = test_bit(i, &tainted_mask) ?
+ t->c_true : t->c_false;
+ }
+ *s = 0;
return buf;
}
--
2.39.2
next prev parent reply other threads:[~2024-03-25 15:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 15:36 [RFC 0/4] kernel/panic: add more descriptive logging of kernel taints Jani Nikula
2024-03-25 15:36 ` Jani Nikula [this message]
2024-03-25 15:36 ` [RFC 2/4] kernel/panic: convert print_tainted() to use struct seq_buf internally Jani Nikula
2024-03-25 15:36 ` [RFC 3/4] kernel/panic: initialize taint_flags[] using a macro Jani Nikula
2024-03-25 15:36 ` [RFC 4/4] kernel/panic: add verbose logging of kernel taints in backtraces Jani Nikula
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=2adfb5b76982d65d83077c8c5b269dbd8a63864a.1711380724.git.jani.nikula@intel.com \
--to=jani.nikula@intel.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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®