* [PATCH] lib/bug: cleanup comment style, types and modernize logging
@ 2026-05-04 20:13 Lucas Poupeau
0 siblings, 0 replies; 2+ messages in thread
From: Lucas Poupeau @ 2026-05-04 20:13 UTC (permalink / raw)
To: petermz, tglx, mingo; +Cc: linux-kernel, Lucas Poupeau
Improve the overall code quality of lib/bug.c by:
- Reformatting the main documentation block to follow the standard
kernel multi-line comment style.
- Replacing 'unsigned' with the preferred 'unsigned int'.
- Converting legacy printk() calls to modern pr_warn() and pr_info()
macros to include proper facility levels and satisfy checkpatch.
Signed-off-by: Lucas Poupeau <lucasp.linux@gmail.com>
---
lib/bug.c | 80 +++++++++++++++++++++++++++----------------------------
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/lib/bug.c b/lib/bug.c
index 224f4cfa4aa3..f4a4df3991b0 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -1,41 +1,41 @@
// SPDX-License-Identifier: GPL-2.0
/*
- Generic support for BUG()
-
- This respects the following config options:
-
- CONFIG_BUG - emit BUG traps. Nothing happens without this.
- CONFIG_GENERIC_BUG - enable this code.
- CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit relative pointers for bug_addr and file
- CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG
-
- CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable
- (though they're generally always on).
-
- CONFIG_GENERIC_BUG is set by each architecture using this code.
-
- To use this, your architecture must:
-
- 1. Set up the config options:
- - Enable CONFIG_GENERIC_BUG if CONFIG_BUG
-
- 2. Implement BUG (and optionally BUG_ON, WARN, WARN_ON)
- - Define HAVE_ARCH_BUG
- - Implement BUG() to generate a faulting instruction
- - NOTE: struct bug_entry does not have "file" or "line" entries
- when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate
- the values accordingly.
-
- 3. Implement the trap
- - In the illegal instruction trap handler (typically), verify
- that the fault was in kernel mode, and call report_bug()
- - report_bug() will return whether it was a false alarm, a warning,
- or an actual bug.
- - You must implement the is_valid_bugaddr(bugaddr) callback which
- returns true if the eip is a real kernel address, and it points
- to the expected BUG trap instruction.
-
- Jeremy Fitzhardinge <jeremy@goop.org> 2006
+ * Generic support for BUG()
+ *
+ * This respects the following config options:
+ *
+ * CONFIG_BUG - emit BUG traps. Nothing happens without this.
+ * CONFIG_GENERIC_BUG - enable this code.
+ * CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit relative pointers for bug_addr and file
+ * CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG
+ *
+ * CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable
+ * (though they're generally always on).
+ *
+ * CONFIG_GENERIC_BUG is set by each architecture using this code.
+ *
+ * To use this, your architecture must:
+ *
+ * 1. Set up the config options:
+ * - Enable CONFIG_GENERIC_BUG if CONFIG_BUG
+ *
+ * 2. Implement BUG (and optionally BUG_ON, WARN, WARN_ON)
+ * - Define HAVE_ARCH_BUG
+ * - Implement BUG() to generate a faulting instruction
+ * - NOTE: struct bug_entry does not have "file" or "line" entries
+ * when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate
+ * the values accordingly.
+ *
+ * 3. Implement the trap
+ * - In the illegal instruction trap handler (typically), verify
+ * that the fault was in kernel mode, and call report_bug()
+ * - report_bug() will return whether it was a false alarm, a warning,
+ * or an actual bug.
+ * - You must implement the is_valid_bugaddr(bugaddr) callback which
+ * returns true if the eip is a real kernel address, and it points
+ * to the expected BUG trap instruction.
+ *
+ * Jeremy Fitzhardinge <jeremy@goop.org> 2006
*/
#define pr_fmt(fmt) fmt
@@ -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)
@@ -191,14 +191,14 @@ void __warn_printf(const char *fmt, struct pt_regs *regs)
}
#endif
- printk("%s", fmt);
+ pr_warn("%s", fmt);
}
static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long bugaddr, struct pt_regs *regs)
{
bool warning, once, done, no_cut, has_args;
const char *file, *fmt;
- unsigned line;
+ unsigned int line;
if (!bug) {
if (!is_valid_bugaddr(bugaddr))
@@ -237,7 +237,7 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long buga
* extra debugging message it writes before triggering the handler.
*/
if (!no_cut) {
- printk(KERN_DEFAULT CUT_HERE);
+ pr_info(CUT_HERE);
__warn_printf(fmt, has_args ? regs : NULL);
}
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] lib/bug: cleanup comment style, types and modernize logging
@ 2026-05-04 20:16 Lucas Poupeau
0 siblings, 0 replies; 2+ messages in thread
From: Lucas Poupeau @ 2026-05-04 20:16 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, Lucas Poupeau
Improve the overall code quality of lib/bug.c by:
- Reformatting the main documentation block to follow the standard
kernel multi-line comment style.
- Replacing 'unsigned' with the preferred 'unsigned int'.
- Converting legacy printk() calls to modern pr_warn() and pr_info()
macros to include proper facility levels and satisfy checkpatch.
Signed-off-by: Lucas Poupeau <lucasp.linux@gmail.com>
---
lib/bug.c | 80 +++++++++++++++++++++++++++----------------------------
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/lib/bug.c b/lib/bug.c
index 224f4cfa4aa3..f4a4df3991b0 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -1,41 +1,41 @@
// SPDX-License-Identifier: GPL-2.0
/*
- Generic support for BUG()
-
- This respects the following config options:
-
- CONFIG_BUG - emit BUG traps. Nothing happens without this.
- CONFIG_GENERIC_BUG - enable this code.
- CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit relative pointers for bug_addr and file
- CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG
-
- CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable
- (though they're generally always on).
-
- CONFIG_GENERIC_BUG is set by each architecture using this code.
-
- To use this, your architecture must:
-
- 1. Set up the config options:
- - Enable CONFIG_GENERIC_BUG if CONFIG_BUG
-
- 2. Implement BUG (and optionally BUG_ON, WARN, WARN_ON)
- - Define HAVE_ARCH_BUG
- - Implement BUG() to generate a faulting instruction
- - NOTE: struct bug_entry does not have "file" or "line" entries
- when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate
- the values accordingly.
-
- 3. Implement the trap
- - In the illegal instruction trap handler (typically), verify
- that the fault was in kernel mode, and call report_bug()
- - report_bug() will return whether it was a false alarm, a warning,
- or an actual bug.
- - You must implement the is_valid_bugaddr(bugaddr) callback which
- returns true if the eip is a real kernel address, and it points
- to the expected BUG trap instruction.
-
- Jeremy Fitzhardinge <jeremy@goop.org> 2006
+ * Generic support for BUG()
+ *
+ * This respects the following config options:
+ *
+ * CONFIG_BUG - emit BUG traps. Nothing happens without this.
+ * CONFIG_GENERIC_BUG - enable this code.
+ * CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit relative pointers for bug_addr and file
+ * CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG
+ *
+ * CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable
+ * (though they're generally always on).
+ *
+ * CONFIG_GENERIC_BUG is set by each architecture using this code.
+ *
+ * To use this, your architecture must:
+ *
+ * 1. Set up the config options:
+ * - Enable CONFIG_GENERIC_BUG if CONFIG_BUG
+ *
+ * 2. Implement BUG (and optionally BUG_ON, WARN, WARN_ON)
+ * - Define HAVE_ARCH_BUG
+ * - Implement BUG() to generate a faulting instruction
+ * - NOTE: struct bug_entry does not have "file" or "line" entries
+ * when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate
+ * the values accordingly.
+ *
+ * 3. Implement the trap
+ * - In the illegal instruction trap handler (typically), verify
+ * that the fault was in kernel mode, and call report_bug()
+ * - report_bug() will return whether it was a false alarm, a warning,
+ * or an actual bug.
+ * - You must implement the is_valid_bugaddr(bugaddr) callback which
+ * returns true if the eip is a real kernel address, and it points
+ * to the expected BUG trap instruction.
+ *
+ * Jeremy Fitzhardinge <jeremy@goop.org> 2006
*/
#define pr_fmt(fmt) fmt
@@ -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)
@@ -191,14 +191,14 @@ void __warn_printf(const char *fmt, struct pt_regs *regs)
}
#endif
- printk("%s", fmt);
+ pr_warn("%s", fmt);
}
static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long bugaddr, struct pt_regs *regs)
{
bool warning, once, done, no_cut, has_args;
const char *file, *fmt;
- unsigned line;
+ unsigned int line;
if (!bug) {
if (!is_valid_bugaddr(bugaddr))
@@ -237,7 +237,7 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long buga
* extra debugging message it writes before triggering the handler.
*/
if (!no_cut) {
- printk(KERN_DEFAULT CUT_HERE);
+ pr_info(CUT_HERE);
__warn_printf(fmt, has_args ? regs : NULL);
}
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-04 20:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 20:16 [PATCH] lib/bug: cleanup comment style, types and modernize logging Lucas Poupeau
-- strict thread matches above, loose matches on Subject: below --
2026-05-04 20:13 Lucas Poupeau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox