]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2009-12-31 BVK Chaitanya <bvk.groups@gmail.com>
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 31 Dec 2009 14:03:09 +0000 (15:03 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 31 Dec 2009 14:03:09 +0000 (15:03 +0100)
* include/grub/list.h (grub_assert_fail): Removed.
(grub_bad_type_cast_real): New function.
(grub_bad_type_cast): New macro.
(GRUB_AS_LIST): Use grub_bad_type_cast.
(GRUB_AS_LIST_P): Likewise.
(GRUB_AS_NAMED_LIST): Likewise.
(GRUB_AS_NAMED_LIST_P): Likewise.
(GRUB_AS_PRIO_LIST): Likewise.
(GRUB_AS_PRIO_LIST_P): Likewise.
* include/grub/handler.h (GRUB_AS_HANDLER): Likewise.

ChangeLog
include/grub/handler.h
include/grub/list.h

index c9a5d4eb2a31ac9b10d2385037cb2c9d5dfea78a..64ebf0e78c8bac316c693aff603e4dee508a72ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-12-31 BVK Chaitanya  <bvk.groups@gmail.com>
+
+       * include/grub/list.h (grub_assert_fail): Removed.
+       (grub_bad_type_cast_real): New function.
+       (grub_bad_type_cast): New macro.
+       (GRUB_AS_LIST): Use grub_bad_type_cast.
+       (GRUB_AS_LIST_P): Likewise.
+       (GRUB_AS_NAMED_LIST): Likewise,
+       (GRUB_AS_NAMED_LIST_P): Likewise.
+       (GRUB_AS_PRIO_LIST): Likewise,
+       (GRUB_AS_PRIO_LIST_P): Likewise.
+       * include/grub/handler.h (GRUB_AS_HANDLER): Likewise,
+
 2009-12-29 Vladimir Serbinenko  <phcoder@gmail.com>
 
        * loader/sparc64/ieee1275/linux.c (GRUB_MOD_INIT (linux)):
index 3331bb4177f619dc583272e911b826053f7d1857..77dd7d9c1e6629ff97d91c1d1098a96d0402cd29 100644 (file)
@@ -55,6 +55,6 @@ grub_err_t EXPORT_FUNC(grub_handler_set_current) (grub_handler_class_t class,
     GRUB_FIELD_MATCH (ptr, grub_handler_t, name) && \
     GRUB_FIELD_MATCH (ptr, grub_handler_t, init) && \
     GRUB_FIELD_MATCH (ptr, grub_handler_t, fini)) ? \
-   (grub_handler_t) ptr : grub_assert_fail ())
+   (grub_handler_t) ptr : grub_bad_type_cast ())
 
 #endif /* ! GRUB_HANDLER_HEADER */
index 2dffdc08d013941a986f97dd25f7dbbe144d0c57..86a5381cdfbcc599184bd3f6b5c3044c7c4062e0 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <grub/symbol.h>
 #include <grub/types.h>
+#include <grub/misc.h>
 
 struct grub_list
 {
@@ -39,31 +40,30 @@ int EXPORT_FUNC(grub_list_iterate) (grub_list_t head, grub_list_hook_t hook);
 void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item,
                                    grub_list_test_t test);
 
-/* This function doesn't exist, so if assertion is false for some reason, the
-   linker would fail.  */
-#ifdef APPLE_CC
-/* This approach fails with Apple's gcc. Use grub_abort.  */
-#include <grub/misc.h>
 static inline void *
-grub_assert_fail (void)
+grub_bad_type_cast_real (int line, const char *file)
+     __attribute__ ((error ("bad type cast between incompatible grub types")));
+
+static inline void *
+grub_bad_type_cast_real (int line, const char *file)
 {
-       grub_abort ();
-       return 0;
+  grub_fatal ("error:%s:%u: bad type cast between incompatible grub types",
+             file, line);
+  return 0;
 }
-#else
-extern void* grub_assert_fail (void);
-#endif
+
+#define grub_bad_type_cast() grub_bad_type_cast_real(__LINE__, __FILE__)
 
 #define GRUB_FIELD_MATCH(ptr, type, field) \
   ((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
 
 #define GRUB_AS_LIST(ptr) \
   (GRUB_FIELD_MATCH (ptr, grub_list_t, next) ? \
-   (grub_list_t) ptr : grub_assert_fail ())
+   (grub_list_t) ptr : grub_bad_type_cast ())
 
 #define GRUB_AS_LIST_P(pptr) \
   (GRUB_FIELD_MATCH (*pptr, grub_list_t, next) ? \
-   (grub_list_t *) (void *) pptr : grub_assert_fail ())
+   (grub_list_t *) (void *) pptr : grub_bad_type_cast ())
 
 struct grub_named_list
 {
@@ -78,12 +78,12 @@ void * EXPORT_FUNC(grub_named_list_find) (grub_named_list_t head,
 #define GRUB_AS_NAMED_LIST(ptr) \
   ((GRUB_FIELD_MATCH (ptr, grub_named_list_t, next) && \
     GRUB_FIELD_MATCH (ptr, grub_named_list_t, name))? \
-   (grub_named_list_t) ptr : grub_assert_fail ())
+   (grub_named_list_t) ptr : grub_bad_type_cast ())
 
 #define GRUB_AS_NAMED_LIST_P(pptr) \
   ((GRUB_FIELD_MATCH (*pptr, grub_named_list_t, next) && \
     GRUB_FIELD_MATCH (*pptr, grub_named_list_t, name))? \
-   (grub_named_list_t *) (void *) pptr : grub_assert_fail ())
+   (grub_named_list_t *) (void *) pptr : grub_bad_type_cast ())
 
 #define GRUB_PRIO_LIST_PRIO_MASK       0xff
 #define GRUB_PRIO_LIST_FLAG_ACTIVE     0x100
@@ -111,12 +111,12 @@ grub_prio_list_remove (grub_prio_list_t *head, grub_prio_list_t item)
   ((GRUB_FIELD_MATCH (ptr, grub_prio_list_t, next) && \
     GRUB_FIELD_MATCH (ptr, grub_prio_list_t, name) && \
     GRUB_FIELD_MATCH (ptr, grub_prio_list_t, prio))? \
-   (grub_prio_list_t) ptr : grub_assert_fail ())
+   (grub_prio_list_t) ptr : grub_bad_type_cast ())
 
 #define GRUB_AS_PRIO_LIST_P(pptr) \
   ((GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, next) && \
     GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, name) && \
     GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prio))? \
-   (grub_prio_list_t *) (void *) pptr : grub_assert_fail ())
+   (grub_prio_list_t *) (void *) pptr : grub_bad_type_cast ())
 
 #endif /* ! GRUB_LIST_HEADER */