Rename assert to CHECK.
To avoid confusion with the usual definition of assert in C which will
sometimes be compiled out and the expression not evaluated. CHECK will
always be evaluated and tested.
Change-Id: I6a36359ecdecdada5c12ebf70c67cffec9574f7d
diff --git a/src/api.c b/src/api.c
index dae8683..fea419a 100644
--- a/src/api.c
+++ b/src/api.c
@@ -19,11 +19,12 @@
#include "hf/arch/cpu.h"
#include "hf/arch/timer.h"
-#include "hf/assert.h"
+#include "hf/check.h"
#include "hf/dlog.h"
#include "hf/mm.h"
#include "hf/spci.h"
#include "hf/spinlock.h"
+#include "hf/static_assert.h"
#include "hf/std.h"
#include "hf/vm.h"
diff --git a/src/arch/aarch64/hftest/power_mgmt.c b/src/arch/aarch64/hftest/power_mgmt.c
index 7970970..e9b2c1b 100644
--- a/src/arch/aarch64/hftest/power_mgmt.c
+++ b/src/arch/aarch64/hftest/power_mgmt.c
@@ -16,8 +16,9 @@
#include "hf/arch/vm/power_mgmt.h"
-#include "hf/assert.h"
+#include "hf/check.h"
#include "hf/spinlock.h"
+#include "hf/static_assert.h"
#include "vmapi/hf/call.h"
diff --git a/src/arch/aarch64/hypervisor/offsets.c b/src/arch/aarch64/hypervisor/offsets.c
index 366a595..1f32581 100644
--- a/src/arch/aarch64/hypervisor/offsets.c
+++ b/src/arch/aarch64/hypervisor/offsets.c
@@ -16,8 +16,8 @@
#include "offsets.h"
-#include "hf/assert.h"
#include "hf/cpu.h"
+#include "hf/static_assert.h"
#define CHECK_OFFSET(name, type, field) \
CHECK_OFFSET_1(#name, name, offsetof(type, field))
diff --git a/src/arch/aarch64/inc/hf/arch/types.h b/src/arch/aarch64/inc/hf/arch/types.h
index 527ce92..980a34c 100644
--- a/src/arch/aarch64/inc/hf/arch/types.h
+++ b/src/arch/aarch64/inc/hf/arch/types.h
@@ -19,8 +19,8 @@
#include <stdalign.h>
#include <stdint.h>
-#include "hf/assert.h"
#include "hf/spci.h"
+#include "hf/static_assert.h"
#define PAGE_BITS 12
#define PAGE_LEVEL_BITS 9
diff --git a/src/cpu.c b/src/cpu.c
index eeea904..daeb1a0 100644
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -21,6 +21,7 @@
#include "hf/arch/cpu.h"
#include "hf/api.h"
+#include "hf/check.h"
#include "hf/dlog.h"
#include "hf/spci.h"
#include "hf/std.h"
@@ -208,7 +209,7 @@
{
size_t index = vcpu - vcpu->vm->vcpus;
- assert(index < UINT16_MAX);
+ CHECK(index < UINT16_MAX);
return index;
}
@@ -251,7 +252,7 @@
struct vm *vm = vcpu->vm;
bool vcpu_was_off;
- assert(vm->id != HF_PRIMARY_VM_ID);
+ CHECK(vm->id != HF_PRIMARY_VM_ID);
vcpu_locked = vcpu_lock(vcpu);
vcpu_was_off = vcpu_is_off(vcpu_locked);
diff --git a/src/load.c b/src/load.c
index 7556533..8b1dce3 100644
--- a/src/load.c
+++ b/src/load.c
@@ -19,13 +19,13 @@
#include <stdbool.h>
#include "hf/api.h"
-#include "hf/assert.h"
#include "hf/boot_params.h"
#include "hf/dlog.h"
#include "hf/layout.h"
#include "hf/memiter.h"
#include "hf/mm.h"
#include "hf/plat/console.h"
+#include "hf/static_assert.h"
#include "hf/std.h"
#include "hf/vm.h"
diff --git a/src/mm.c b/src/mm.c
index be87e69..ee9384a 100644
--- a/src/mm.c
+++ b/src/mm.c
@@ -19,10 +19,11 @@
#include <stdatomic.h>
#include <stdint.h>
-#include "hf/assert.h"
+#include "hf/check.h"
#include "hf/dlog.h"
#include "hf/layout.h"
#include "hf/plat/console.h"
+#include "hf/static_assert.h"
/**
* This file has functions for managing the level 1 and 2 page tables used by
@@ -500,7 +501,7 @@
* Assert condition to communicate the API constraint of mm_max_level(),
* that isn't encoded in the types, to the static analyzer.
*/
- assert(root_level >= 2);
+ CHECK(root_level >= 2);
/* Cap end to stay within the bounds of the page table. */
if (end > ptable_end) {
@@ -875,7 +876,7 @@
void mm_unlock_stage1(struct mm_stage1_locked *lock)
{
- assert(lock->ptable == &ptable);
+ CHECK(lock->ptable == &ptable);
sl_unlock(&ptable_lock);
lock->ptable = NULL;
}
diff --git a/src/vm.c b/src/vm.c
index 7c5166b..0119fd8 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -17,6 +17,7 @@
#include "hf/vm.h"
#include "hf/api.h"
+#include "hf/check.h"
#include "hf/cpu.h"
#include "hf/spci.h"
#include "hf/std.h"
@@ -115,6 +116,6 @@
*/
struct vcpu *vm_get_vcpu(struct vm *vm, spci_vcpu_index_t vcpu_index)
{
- assert(vcpu_index < vm->vcpu_count);
+ CHECK(vcpu_index < vm->vcpu_count);
return &vm->vcpus[vcpu_index];
}