From 545a397fa607c8d4e68adc7e797c42134930177f Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 29 Aug 2013 12:19:09 +0200 Subject: [PATCH] hw: avoid mandatory function calls in assertions ref #528 --- base-hw/src/core/include/platform_pd.h | 8 +++++--- base-hw/src/core/kernel.cc | 9 +++++---- base-hw/src/core/kernel/thread.h | 2 +- base-hw/src/core/platform_thread.cc | 6 ++++-- base-hw/src/core/rm_session_support.cc | 12 +++++++----- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/base-hw/src/core/include/platform_pd.h b/base-hw/src/core/include/platform_pd.h index f546ef651f..6f5cc3ffa0 100644 --- a/base-hw/src/core/include/platform_pd.h +++ b/base-hw/src/core/include/platform_pd.h @@ -51,10 +51,12 @@ namespace Genode Platform_pd(char const *label) : _main_thread(0), _label(label) { /* get some aligned space for the kernel object */ - void * kernel_pd; + void * kernel_pd = 0; Range_allocator * ram = platform()->ram_alloc(); - assert(ram->alloc_aligned(Kernel::pd_size(), &kernel_pd, - Kernel::pd_alignm_log2()).is_ok()) + bool kernel_pd_ok = + ram->alloc_aligned(Kernel::pd_size(), &kernel_pd, + Kernel::pd_alignm_log2()).is_ok(); + assert(kernel_pd_ok); /* create kernel object */ _id = Kernel::new_pd(kernel_pd, this); diff --git a/base-hw/src/core/kernel.cc b/base-hw/src/core/kernel.cc index 1b1cc08f53..e9879102ad 100644 --- a/base-hw/src/core/kernel.cc +++ b/base-hw/src/core/kernel.cc @@ -852,12 +852,13 @@ namespace Kernel void handle_pagefault(Thread * const user) { /* check out cause and attributes of abort */ - addr_t va; - bool w; - assert(user->translation_miss(va, w)); + addr_t virt_addr = 0; + bool write = 0; + bool is_transl_miss = user->translation_miss(virt_addr, write); + assert(is_transl_miss); /* the user might be able to resolve the pagefault */ - user->pagefault(va, w); + user->pagefault(virt_addr, write); } diff --git a/base-hw/src/core/kernel/thread.h b/base-hw/src/core/kernel/thread.h index 29bb476c36..1d35b5aea8 100644 --- a/base-hw/src/core/kernel/thread.h +++ b/base-hw/src/core/kernel/thread.h @@ -183,7 +183,7 @@ namespace Kernel */ unsigned alloc() { - if (!_valid_id(_first_free_id)) assert(0); + assert(_valid_id(_first_free_id)); _free[_first_free_id] = 0; unsigned const id = _first_free_id; _first_free_id_assigned(); diff --git a/base-hw/src/core/platform_thread.cc b/base-hw/src/core/platform_thread.cc index 3c12c34e12..5f7a372ebf 100644 --- a/base-hw/src/core/platform_thread.cc +++ b/base-hw/src/core/platform_thread.cc @@ -71,8 +71,10 @@ Platform_thread::Platform_thread(const char * name, /* create UTCB for a core thread */ Range_allocator * const ram = platform()->ram_alloc(); - assert(ram->alloc_aligned(sizeof(Native_utcb), (void **)&_phys_utcb, - MIN_MAPPING_SIZE_LOG2).is_ok()); + bool phys_utcb_ok = ram->alloc_aligned(sizeof(Native_utcb), + (void **)&_phys_utcb, + MIN_MAPPING_SIZE_LOG2).is_ok(); + assert(phys_utcb_ok); _virt_utcb = _phys_utcb; /* common constructor parts */ diff --git a/base-hw/src/core/rm_session_support.cc b/base-hw/src/core/rm_session_support.cc index a1cad4e538..3f02169afa 100644 --- a/base-hw/src/core/rm_session_support.cc +++ b/base-hw/src/core/rm_session_support.cc @@ -70,14 +70,16 @@ void Ipc_pager::resolve_and_wait_for_fault() _mapping.size_log2, flags); if (sl2) { - /* try to get some natural aligned space */ - void * space; - assert(platform()->ram_alloc()->alloc_aligned(1<ram_alloc()->alloc_aligned(1<insert_translation(_mapping.virt_address, _mapping.phys_address, - _mapping.size_log2, flags, space); + _mapping.size_log2, flags, ram); assert(!sl2); } /* wake up faulter */