aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-06-29 09:50:00 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2012-06-29 09:50:00 -0700
commit4ecc2eee96ca522e0cd4f00d2d27e3f2df90bc08 (patch)
tree00cdeefb460395140aadac2a8763122f93abf599
parent6cad5d1c2d72330ecd2a749954a0de1927a0474e (diff)
downloadsyslinux-4ecc2eee96ca522e0cd4f00d2d27e3f2df90bc08.tar.gz
syslinux-4ecc2eee96ca522e0cd4f00d2d27e3f2df90bc08.tar.xz
syslinux-4ecc2eee96ca522e0cd4f00d2d27e3f2df90bc08.zip
SEG(): centralize the bad bailout
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--com32/include/com32.h10
-rw-r--r--core/kaboom.c12
2 files changed, 16 insertions, 6 deletions
diff --git a/com32/include/com32.h b/com32/include/com32.h
index db85f773..148d08eb 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -136,15 +136,13 @@ char *lstrdup(const char *);
* pointer is actually reachable from the target segment.
*/
#if defined(DEBUG) && (defined(__COM32__) || defined(__SYSLINUX_CORE__))
-#include <dprintf.h>
-__noreturn _kaboom(void);
+__noreturn __bad_SEG(const volatile void *);
static inline uint16_t SEG(const volatile void *__p)
{
- if (__unlikely((uintptr_t)__p > 0xfffff)) {
- dprintf("Non-lowmem pointer passed to SEG(): %p\n", __p);
- _kaboom();
- }
+ if (__unlikely((uintptr_t)__p > 0xfffff))
+ __bad_SEG(__p);
+
return (uint16_t) (((uintptr_t) __p) >> 4);
}
#else
diff --git a/core/kaboom.c b/core/kaboom.c
index d639915a..9bb30736 100644
--- a/core/kaboom.c
+++ b/core/kaboom.c
@@ -4,6 +4,18 @@
#include "core.h"
+#ifdef DEBUG
+
+#include <dprintf.h>
+
+__noreturn __bad_SEG(const volatile void *p)
+{
+ dprintf("SEG() passed an invalid pointer: %p\n", p);
+ kaboom();
+}
+
+#endif
+
#undef kaboom
__noreturn _kaboom(void)