#define BUGFRAME_bug 1
#define BUGFRAME_assert 2
+#define BUGFRAME_NR 3
+
/* Many versions of GCC doesn't support the asm %c parameter which would
* be preferable to this unpleasantness. We use mergeable string
* sections to avoid multiple copies of the string appearing in the
*/
#define BUG_FRAME(type, line, file, has_msg, msg) do { \
BUILD_BUG_ON((line) >> 16); \
+ BUILD_BUG_ON((type) >= BUGFRAME_NR); \
asm ("1:"BUG_INSTR"\n" \
".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \
"2:\t.asciz " __stringify(file) "\n" \
#define BUGFRAME_bug 2
#define BUGFRAME_assert 3
+#define BUGFRAME_NR 4
+
#ifndef __ASSEMBLY__
struct bug_frame {
#define BUG_FRAME(type, line, ptr, second_frame, msg) do { \
BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE_HI_WIDTH)); \
+ BUILD_BUG_ON((type) >= BUGFRAME_NR); \
asm volatile ( _ASM_BUGFRAME_TEXT(second_frame) \
:: _ASM_BUGFRAME_INFO(type, line, ptr, msg) ); \
} while (0)
* in .rodata
*/
.macro BUG_FRAME type, line, file_str, second_frame, msg
+
+ .if \type >= BUGFRAME_NR
+ .error "Invalid BUGFRAME index"
+ .endif
+
.L\@ud: ud2a
.pushsection .rodata.str1, "aMS", @progbits, 1