mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-21 00:23:16 +00:00
base: avoid implicit conversions
This patch is a prerequisite for compiling the code with the warnings -Wconversion enabled. Issue #23
This commit is contained in:
@ -29,7 +29,7 @@ static void out_mem(char const c)
|
||||
{
|
||||
pos.value = cur_pos;
|
||||
data[cur_pos++] = c;
|
||||
return cur_pos % (range.size - sizeof(Log_memory::Header));
|
||||
return (unsigned)(cur_pos % (range.size - sizeof(Log_memory::Header)));
|
||||
}
|
||||
} __attribute__((packed)) * mem = reinterpret_cast<Log_memory *>(range.start);
|
||||
|
||||
|
@ -37,7 +37,7 @@ Range_allocator::Alloc_result
|
||||
Mapped_mem_allocator::alloc_aligned(size_t size, unsigned align, Range range)
|
||||
{
|
||||
size_t page_rounded_size = align_addr(size, get_page_size_log2());
|
||||
align = max((size_t)align, get_page_size_log2());
|
||||
align = max((int)align, (int)get_page_size_log2());
|
||||
|
||||
/* allocate physical pages */
|
||||
return _phys_alloc->alloc_aligned(page_rounded_size, align, range)
|
||||
|
@ -270,10 +270,10 @@ Cpu_session_component::Cpu_session_component(Rpc_entrypoint &session_ep,
|
||||
{
|
||||
Arg a = Arg_string::find_arg(args, "priority");
|
||||
if (a.valid()) {
|
||||
_priority = a.ulong_value(0);
|
||||
_priority = (unsigned)a.ulong_value(0);
|
||||
|
||||
/* clamp priority value to valid range */
|
||||
_priority = min((unsigned)PRIORITY_LIMIT - 1, _priority);
|
||||
_priority = min((unsigned)(PRIORITY_LIMIT - 1), _priority);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Genode::Constrained_core_ram : public Allocator
|
||||
core_mem_allocated -= page_aligned_size;
|
||||
}
|
||||
|
||||
size_t consumed() const override { return core_mem_allocated; }
|
||||
size_t consumed() const override { return (size_t)core_mem_allocated; }
|
||||
size_t overhead(size_t) const override { return 0; }
|
||||
bool need_size_for_free() const override { return true; }
|
||||
};
|
||||
|
@ -134,7 +134,7 @@ class Genode::Mapped_mem_allocator : public Genode::Core_mem_translator
|
||||
* \param phys_addr start address of physical range
|
||||
* \param size size of range
|
||||
*/
|
||||
bool _map_local(addr_t virt_addr, addr_t phys_addr, unsigned size);
|
||||
bool _map_local(addr_t virt_addr, addr_t phys_addr, size_t size);
|
||||
|
||||
/**
|
||||
* Destroy mapping between physical and virtual address range
|
||||
@ -145,7 +145,7 @@ class Genode::Mapped_mem_allocator : public Genode::Core_mem_translator
|
||||
* \param phys_addr start address of physical range
|
||||
* \param size size of range
|
||||
*/
|
||||
bool _unmap_local(addr_t virt_addr, addr_t phys_addr, unsigned size);
|
||||
bool _unmap_local(addr_t virt_addr, addr_t phys_addr, size_t size);
|
||||
|
||||
|
||||
/***********************************
|
||||
@ -180,7 +180,7 @@ class Genode::Mapped_mem_allocator : public Genode::Core_mem_translator
|
||||
*************************/
|
||||
|
||||
Alloc_result try_alloc(size_t size) override {
|
||||
return alloc_aligned(size, log2(sizeof(addr_t))); }
|
||||
return alloc_aligned(size, (unsigned)log2(sizeof(addr_t))); }
|
||||
void free(void *addr, size_t) override;
|
||||
size_t consumed() const override { return _phys_alloc->consumed(); }
|
||||
size_t overhead(size_t size) const override {
|
||||
@ -304,7 +304,7 @@ class Genode::Core_mem_allocator : public Genode::Core_mem_translator
|
||||
|
||||
Alloc_result try_alloc(size_t size) override
|
||||
{
|
||||
return alloc_aligned(size, log2(sizeof(addr_t)));
|
||||
return alloc_aligned(size, (unsigned)log2(sizeof(addr_t)));
|
||||
}
|
||||
|
||||
void free(void *addr, size_t size) override
|
||||
|
@ -38,7 +38,7 @@ class Genode::Trace::Root : public Genode::Root_component<Session_component>
|
||||
{
|
||||
size_t ram_quota = Arg_string::find_arg(args, "ram_quota").ulong_value(0);
|
||||
size_t arg_buffer_size = Arg_string::find_arg(args, "arg_buffer_size").ulong_value(0);
|
||||
unsigned parent_levels = Arg_string::find_arg(args, "parent_levels").ulong_value(0);
|
||||
unsigned parent_levels = (unsigned)Arg_string::find_arg(args, "parent_levels").ulong_value(0);
|
||||
|
||||
if (arg_buffer_size > ram_quota)
|
||||
throw Service_denied();
|
||||
|
@ -38,7 +38,7 @@ class Genode::Vm_root : public Root_component<Vm_session_component>
|
||||
unsigned priority = 0;
|
||||
Arg a = Arg_string::find_arg(args, "priority");
|
||||
if (a.valid()) {
|
||||
priority = a.ulong_value(0);
|
||||
priority = (unsigned)a.ulong_value(0);
|
||||
|
||||
/* clamp priority value to valid range */
|
||||
priority = min((unsigned)Cpu_session::PRIORITY_LIMIT - 1, priority);
|
||||
|
@ -52,7 +52,7 @@ Ram_dataspace_factory::try_alloc(size_t ds_size, Cache cache)
|
||||
Phys_range const range { .start = high_start, .end = _phys_range.end };
|
||||
|
||||
for (size_t align_log2 = log2(ds_size); align_log2 >= 12; align_log2--) {
|
||||
allocated_range = _phys_alloc.alloc_aligned(ds_size, align_log2, range);
|
||||
allocated_range = _phys_alloc.alloc_aligned(ds_size, (unsigned)align_log2, range);
|
||||
if (allocated_range.ok())
|
||||
break;
|
||||
}
|
||||
@ -61,7 +61,7 @@ Ram_dataspace_factory::try_alloc(size_t ds_size, Cache cache)
|
||||
/* apply constraints, or retry if larger memory allocation failed */
|
||||
if (!allocated_range.ok()) {
|
||||
for (size_t align_log2 = log2(ds_size); align_log2 >= 12; align_log2--) {
|
||||
allocated_range = _phys_alloc.alloc_aligned(ds_size, align_log2, _phys_range);
|
||||
allocated_range = _phys_alloc.alloc_aligned(ds_size, (unsigned)align_log2, _phys_range);
|
||||
if (allocated_range.ok())
|
||||
break;
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ Region_map_component::attach(Dataspace_capability ds_cap, size_t size,
|
||||
continue;
|
||||
|
||||
/* try allocating the align region */
|
||||
_map.alloc_aligned(size, align_log2).with_result(
|
||||
_map.alloc_aligned(size, (unsigned)align_log2).with_result(
|
||||
|
||||
[&] (void *ptr) {
|
||||
attach_at = ptr;
|
||||
|
@ -39,7 +39,7 @@ void Signal_source_component::submit(Signal_context_component &context,
|
||||
* signal will be delivered as result of the next
|
||||
* 'wait_for_signal' call.
|
||||
*/
|
||||
context.increment_signal_cnt(cnt);
|
||||
context.increment_signal_cnt((int)cnt);
|
||||
|
||||
/*
|
||||
* If the client is blocking at the signal source (indicated by
|
||||
|
@ -31,8 +31,8 @@ Io_port_session_component::Io_port_session_component(Range_allocator &io_port_al
|
||||
: _io_port_alloc(io_port_alloc)
|
||||
{
|
||||
/* parse for port properties */
|
||||
unsigned base = Arg_string::find_arg(args, "io_port_base").ulong_value(0);
|
||||
unsigned size = Arg_string::find_arg(args, "io_port_size").ulong_value(0);
|
||||
uint16_t const base = (uint16_t)Arg_string::find_arg(args, "io_port_base").ulong_value(0);
|
||||
uint16_t const size = (uint16_t)Arg_string::find_arg(args, "io_port_size").ulong_value(0);
|
||||
|
||||
/* allocate region (also checks out-of-bounds regions) */
|
||||
io_port_alloc.alloc_addr(size, base).with_error(
|
||||
|
Reference in New Issue
Block a user