[PATCH 2/3] lib/bug: clean up types in bug reporting helpers

From: Josh Law

Date: Sun Mar 15 2026 - 15:50:46 EST


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@xxxxxxxxxxxxx>
---
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