aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-07-07 07:02:46 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-07-07 07:02:46 +0300
commitb97967ab660243b723f246db03c2e4a82e125f3f (patch)
treed30ef3f9dbbc33453c868282b749018659fb6a6b /include
parent122374c362ba8bb9082385da3c82e264ab594f15 (diff)
downloadkmi-b97967ab660243b723f246db03c2e4a82e125f3f.tar.gz
kmi-b97967ab660243b723f246db03c2e4a82e125f3f.zip
simplify assertions
+ No real point having multiple different levels of assertions, just say you assert something and be done with it
Diffstat (limited to 'include')
-rw-r--r--include/kmi/assert.h46
-rw-r--r--include/libfdt.h4
2 files changed, 5 insertions, 45 deletions
diff --git a/include/kmi/assert.h b/include/kmi/assert.h
index 291f15f..3120edc 100644
--- a/include/kmi/assert.h
+++ b/include/kmi/assert.h
@@ -30,57 +30,17 @@
*
* @param x Condition to check for.
*/
-#define catastrophic_assert(x) \
+#define assert(x) \
do { \
if (unlikely(!(x))) { \
- error("catastrophic assertion failed: " QUOTE(x) "\n"); \
+ error("assertion failed: " QUOTE(x) "\n"); \
while (1) { \
} \
} \
} while (0);
-/**
- * The function cannot continue without this assertion, but doesn't necessarily
- * mean that the kernel is borked.
- *
- * @warning Implicit return.
- *
- * @param x Condition to check for.
- * @param r Return value on failed check.
- */
-#define hard_assert(x, r) \
- { \
- if (unlikely(!(x))) { \
- warn("hard assertion failed: " QUOTE(x) "\n"); \
- return r; \
- } \
- }
-
-/**
- * Unexpected case, but not likely to cause problems, likely a bug.
- *
- * @param x Condition to check for.
- */
-#define soft_assert(x) \
- do { \
- if (unlikely(!(x))) { \
- info("soft assertion failed: " QUOTE(x) "\n"); \
- } \
- } while (0);
#else
-#define catastrophic_assert(x)
-#define hard_assert(x, r)
-#define soft_assert(x)
+#define assert(x)
#endif
-/**
- * Use when return value doesn't exist.
- *
- * Example:
- * @code{.c}
- * void func() { hard_assert(x, RETURN_VOID); }
- * @endcode
- */
-#define RETURN_VOID
-
#endif /* KMI_ASSERT_H */
diff --git a/include/libfdt.h b/include/libfdt.h
index c1d6a4e..e9eb905 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -99,7 +99,7 @@ void __dbg_fdt(const void *fdt, int node_offset, int depth);
static inline fdt64_t fdt_load_reg_addr(struct cell_info ci, const void *p,
size_t i)
{
- catastrophic_assert(ci.addr_cells == 2 || ci.addr_cells == 1);
+ assert(ci.addr_cells == 2 || ci.addr_cells == 1);
size_t offset = i * (ci.addr_cells + ci.size_cells) * sizeof(fdt32_t);
char *addr = ((char *)p) + 0;
return fdt_load_int_ptr(ci.addr_cells, addr + offset);
@@ -116,7 +116,7 @@ static inline fdt64_t fdt_load_reg_addr(struct cell_info ci, const void *p,
static inline fdt64_t fdt_load_reg_size(struct cell_info ci, const void *p,
size_t i)
{
- hard_assert(ci.size_cells == 2 || ci.size_cells == 1, 0);
+ assert(ci.size_cells == 2 || ci.size_cells == 1);
size_t offset = i * (ci.addr_cells + ci.size_cells) * sizeof(fdt32_t);
char *addr = ((char *)p) + ci.addr_cells * sizeof(fdt32_t);
return fdt_load_int_ptr(ci.size_cells, addr + offset);