Skip to content

Commit 30b8256

Browse files
author
Peter Zijlstra
committed
bug: Clean up CONFIG_GENERIC_BUG_RELATIVE_POINTERS
Three repeated CONFIG_GENERIC_BUG_RELATIVE_POINTERS #ifdefs right after one another yields unreadable code. Add a helper. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20251110115757.341703850@infradead.org
1 parent d292dbb commit 30b8256

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

include/asm-generic/bug.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,20 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
3535

3636
#ifdef CONFIG_BUG
3737

38-
#ifdef CONFIG_GENERIC_BUG
39-
struct bug_entry {
4038
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
41-
unsigned long bug_addr;
39+
#define BUG_REL(type, name) type name
4240
#else
43-
signed int bug_addr_disp;
41+
#define BUG_REL(type, name) signed int name##_disp
4442
#endif
43+
44+
#ifdef CONFIG_GENERIC_BUG
45+
struct bug_entry {
46+
BUG_REL(unsigned long, bug_addr);
4547
#ifdef HAVE_ARCH_BUG_FORMAT
46-
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
47-
const char *format;
48-
#else
49-
signed int format_disp;
50-
#endif
48+
BUG_REL(const char *, format);
5149
#endif
5250
#ifdef CONFIG_DEBUG_BUGVERBOSE
53-
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
54-
const char *file;
55-
#else
56-
signed int file_disp;
57-
#endif
51+
BUG_REL(const char *, file);
5852
unsigned short line;
5953
#endif
6054
unsigned short flags;

0 commit comments

Comments
 (0)