summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kernel/arch/i386/interrupts/idt.c2
-rw-r--r--src/kernel/panic.h2
-rw-r--r--src/kernel/syscalls.c4
-rw-r--r--src/kernel/vfs/path.c3
4 files changed, 6 insertions, 5 deletions
diff --git a/src/kernel/arch/i386/interrupts/idt.c b/src/kernel/arch/i386/interrupts/idt.c
index 0b327c8..75c221f 100644
--- a/src/kernel/arch/i386/interrupts/idt.c
+++ b/src/kernel/arch/i386/interrupts/idt.c
@@ -58,7 +58,7 @@ static void idt_load() {
static void idt_test() {
asm("int $0x34" : : : "memory");
- if (!isr_test_interrupt_called) panic();
+ assert(isr_test_interrupt_called);
}
void idt_init() {
diff --git a/src/kernel/panic.h b/src/kernel/panic.h
index 1e25a83..9407e44 100644
--- a/src/kernel/panic.h
+++ b/src/kernel/panic.h
@@ -8,3 +8,5 @@
tty_const(" (" __FILE__ ":" NUM2STR(__LINE__) ") "); \
halt_cpu(); \
} while (0)
+
+#define assert(stmt) do { if (!(stmt)) panic(); } while (0)
diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c
index bdf77af..09b3507 100644
--- a/src/kernel/syscalls.c
+++ b/src/kernel/syscalls.c
@@ -9,8 +9,8 @@ _Noreturn static void await_finish(struct process *dead, struct process *listene
size_t len;
bool res;
- if ( dead->state != PS_DEAD ) panic();
- if (listener->state != PS_WAITS4CHILDDEATH) panic();
+ assert(dead->state == PS_DEAD);
+ assert(listener->state == PS_WAITS4CHILDDEATH);
dead->state = PS_DEADER;
listener->state = PS_RUNNING;
diff --git a/src/kernel/vfs/path.c b/src/kernel/vfs/path.c
index 1cdcfe4..dad4373 100644
--- a/src/kernel/vfs/path.c
+++ b/src/kernel/vfs/path.c
@@ -11,8 +11,7 @@ int path_simplify(const char *in, char *out, size_t len) {
bool directory = 0;
for (int i = 0; i < len; i += seg_len + 1) {
- // TODO implement assert
- if (in[i] != '/') panic();
+ assert(in[i] == '/');
seg_len = 0;
directory = false;