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:
Norman Feske
2021-12-02 11:21:14 +01:00
parent c79a59655d
commit 03047009b1
189 changed files with 947 additions and 819 deletions

View File

@ -100,9 +100,9 @@ addr_t Cap_range::alloc(size_t const num_log2)
do {
/* align i to num_log2 */
unsigned i = ((_base + last + step - 1) & ~(step - 1)) - _base;
unsigned i = (unsigned)(((_base + last + step - 1) & ~(step - 1)) - _base);
unsigned j;
for (; i + step < max; i += step) {
for (; i + step < max; i += (unsigned)step) {
for (j = 0; j < step; j++)
if (_cap_array[i+j])
break;
@ -116,7 +116,7 @@ addr_t Cap_range::alloc(size_t const num_log2)
return _base + i;
}
max = last;
max = (unsigned)last;
last = 0;
} while (max);
@ -157,7 +157,7 @@ addr_t Capability_map::insert(size_t const num_log_2, addr_t const sel)
return ~0UL;
for (unsigned i = 0; i < 1UL << num_log_2; i++)
range->inc(sel + i - range->base());
range->inc((unsigned)(sel + i - range->base()));
return sel;
}
@ -170,13 +170,13 @@ void Capability_map::remove(Genode::addr_t const sel, uint8_t num_log_2,
if (!range)
return;
range->dec(sel - range->base(), revoke, num_log_2);
range->dec((unsigned)(sel - range->base()), revoke, num_log_2);
Genode::addr_t last_sel = sel + (1UL << num_log_2);
Genode::addr_t last_range = range->base() + range->elements();
while (last_sel > last_range) {
uint8_t left_log2 = log2(last_sel - last_range);
uint8_t left_log2 = (uint8_t)log2(last_sel - last_range);
/* take care for a case which should not happen */
if (left_log2 >= sizeof(last_range)*8) {

View File

@ -42,7 +42,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
/* calculate max order of caps to be received during reply */
unsigned short log2_max = 0;
if (rcv_caps) {
log2_max = log2(rcv_caps);
log2_max = (uint16_t)log2(rcv_caps);
/* if this happens, the call is bogus and invalid */
if ((log2_max >= sizeof(rcv_caps) * 8))
@ -93,7 +93,7 @@ Rpc_exception_code Genode::ipc_call(Native_capability dst,
if (utcb.msg_words() < 1)
return Rpc_exception_code(Rpc_exception_code::INVALID_OBJECT);
return Rpc_exception_code(copy_utcb_to_msgbuf(utcb, rcv_window, rcv_msg));
return Rpc_exception_code((int)copy_utcb_to_msgbuf(utcb, rcv_window, rcv_msg));
}

View File

@ -83,8 +83,8 @@ void prepare_init_main_thread()
enum { CAP_RANGES = 32 };
unsigned index = initial_cap_range().base() +
initial_cap_range().elements();
unsigned index = (unsigned)(initial_cap_range().base() +
initial_cap_range().elements());
static char local[CAP_RANGES][sizeof(Cap_range)];
@ -95,7 +95,7 @@ void prepare_init_main_thread()
cap_map().insert(range);
index = range.base() + range.elements();
index = (unsigned)(range.base() + range.elements());
}
}
}

View File

@ -389,7 +389,7 @@ void Nova_vcpu::_write_nova_state(Nova::Utcb &utcb)
utcb.dr7 = state().dr7.value();
}
if (state().r8.charged() || state().r9.charged() ||
if (state().r8 .charged() || state().r9 .charged() ||
state().r10.charged() || state().r11.charged() ||
state().r12.charged() || state().r13.charged() ||
state().r14.charged() || state().r15.charged()) {
@ -527,10 +527,10 @@ void Nova_vcpu::_write_nova_state(Nova::Utcb &utcb)
state().pdpte_2.charged() || state().pdpte_3.charged()) {
utcb.mtd |= Nova::Mtd::PDPTE;
utcb.pdpte[0] = state().pdpte_0.value();
utcb.pdpte[1] = state().pdpte_1.value();
utcb.pdpte[2] = state().pdpte_2.value();
utcb.pdpte[3] = state().pdpte_3.value();
utcb.pdpte[0] = (Nova::mword_t)state().pdpte_0.value();
utcb.pdpte[1] = (Nova::mword_t)state().pdpte_1.value();
utcb.pdpte[2] = (Nova::mword_t)state().pdpte_2.value();
utcb.pdpte[3] = (Nova::mword_t)state().pdpte_3.value();
}
if (state().star.charged() || state().lstar.charged() ||
@ -538,7 +538,7 @@ void Nova_vcpu::_write_nova_state(Nova::Utcb &utcb)
state().kernel_gs_base.charged()) {
utcb.mtd |= Nova::Mtd::SYSCALL_SWAPGS;
utcb.write_star(state().star.value());
utcb.write_star (state().star.value());
utcb.write_lstar(state().lstar.value());
utcb.write_cstar(state().cstar.value());
utcb.write_fmask(state().fmask.value());
@ -783,7 +783,7 @@ Nova_vcpu::Nova_vcpu(Env &env, Vm_connection &vm, Allocator &alloc,
Nova::Mtd mtd = _portal_mtd(i, exit_config);
if (mtd.value()) {
signal_exit = _create_exit_handler(env.pd(), handler, vcpu_id, i, mtd);
signal_exit = _create_exit_handler(env.pd(), handler, vcpu_id, (uint16_t)i, mtd);
} else {
signal_exit = dontcare_exit;
}