mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Law <objecting@objecting.org>
To: Andrew Morton <akpm@linux-foundation.org>,
	Josh Law <objecting@objecting.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] lib/bug: clean up types in bug reporting helpers
Date: Sun, 15 Mar 2026 19:49:38 +0000	[thread overview]
Message-ID: <20260315194939.328612-3-objecting@objecting.org> (raw)
In-Reply-To: <20260315194939.328612-1-objecting@objecting.org>

Add const to the bug_entry parameter of bug_get_file_line() and
bug_get_format() since they only read from the structure.  Update
the declaration in include/linux/bug.h to match.

While here, replace bare 'unsigned' with 'unsigned int' for the loop
counter in module_find_bug() and the line number in __report_bug().

Signed-off-by: Josh Law <objecting@objecting.org>
---
 include/linux/bug.h | 6 +++---
 lib/bug.c           | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/linux/bug.h b/include/linux/bug.h
index 17a4933c611b..01a996eed8d8 100644
--- a/include/linux/bug.h
+++ b/include/linux/bug.h
@@ -36,7 +36,7 @@ static inline int is_warning_bug(const struct bug_entry *bug)
 	return bug->flags & BUGFLAG_WARNING;
 }
 
-void bug_get_file_line(struct bug_entry *bug, const char **file,
+void bug_get_file_line(const struct bug_entry *bug, const char **file,
 		       unsigned int *line);
 
 struct bug_entry *find_bug(unsigned long bugaddr);
@@ -70,8 +70,8 @@ report_bug_entry(struct bug_entry *bug, struct pt_regs *regs)
 	return BUG_TRAP_TYPE_BUG;
 }
 
-static inline void bug_get_file_line(struct bug_entry *bug, const char **file,
-				     unsigned int *line)
+static inline void bug_get_file_line(const struct bug_entry *bug,
+				     const char **file, unsigned int *line)
 {
 	*file = NULL;
 	*line = 0;
diff --git a/lib/bug.c b/lib/bug.c
index 037c7370dadf..9d76703ff7d1 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -71,7 +71,7 @@ static struct bug_entry *module_find_bug(unsigned long bugaddr)
 
 	guard(rcu)();
 	list_for_each_entry_rcu(mod, &module_bug_list, bug_list) {
-		unsigned i;
+		unsigned int i;
 
 		bug = mod->bug_table;
 		for (i = 0; i < mod->num_bugs; ++i, ++bug)
@@ -123,7 +123,7 @@ static inline struct bug_entry *module_find_bug(unsigned long bugaddr)
 }
 #endif
 
-void bug_get_file_line(struct bug_entry *bug, const char **file,
+void bug_get_file_line(const struct bug_entry *bug, const char **file,
 		       unsigned int *line)
 {
 #ifdef CONFIG_DEBUG_BUGVERBOSE
@@ -139,7 +139,7 @@ void bug_get_file_line(struct bug_entry *bug, const char **file,
 #endif
 }
 
-static const char *bug_get_format(struct bug_entry *bug)
+static const char *bug_get_format(const struct bug_entry *bug)
 {
 	const char *format = NULL;
 #ifdef HAVE_ARCH_BUG_FORMAT
@@ -202,7 +202,7 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long buga
 	bool warning, once, done, no_cut, has_args;
 	const char *file, *fmt;
 	unsigned short flags;
-	unsigned line;
+	unsigned int line;
 
 	if (!bug) {
 		if (!is_valid_bugaddr(bugaddr))
-- 
2.34.1


  parent reply	other threads:[~2026-03-15 19:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-15 19:49 [PATCH 0/3] lib/bug: concurrency fix, cleanups, and debugfs inspection Josh Law
2026-03-15 19:49 ` [PATCH 1/3] lib/bug: annotate concurrent access to bug->flags with READ_ONCE/WRITE_ONCE Josh Law
2026-03-15 19:49 ` Josh Law [this message]
2026-03-15 19:49 ` [PATCH 3/3] lib/bug: add debugfs interface to list all BUG/WARN sites Josh Law

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=20260315194939.328612-3-objecting@objecting.org \
    --to=objecting@objecting.org \
    --cc=akpm@linux-foundation.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®