Skip to content

Commit

Permalink
fix(signedness): Change variables signedness to match the operation
Browse files Browse the repository at this point in the history
The flag -wextra forces comparisons and other operations to have elements
with the same signedness. In the commit, we change some variables types to
match the operations they are used, or cast them to the correct type.

Signed-off-by: Miguel Silva <[email protected]>
  • Loading branch information
miguelafsilva5 committed May 17, 2024
1 parent b4dc9ea commit 3cbb083
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/arch/armv8/armv8-r/mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static inline mem_attrs_t mpu_entry_attrs(struct mp_region* mpr)
static mpid_t mpu_entry_allocate()
{
mpid_t reg_num = INVALID_MPID;
for (mpid_t i = 0; i < mpu_num_entries(); i++) {
for (mpid_t i = 0; i < (ssize_t)mpu_num_entries(); i++) {
if (bitmap_get(cpu()->arch.profile.mpu.bitmap, i) == 0) {
bitmap_set(cpu()->arch.profile.mpu.bitmap, i);
reg_num = i;
Expand Down Expand Up @@ -546,7 +546,7 @@ void mpu_init()
bitmap_clear_consecutive(cpu()->arch.profile.mpu.bitmap, 0, mpu_num_entries());
list_init(&cpu()->arch.profile.mpu.order.list);

for (mpid_t mpid = 0; mpid < mpu_num_entries(); mpid++) {
for (mpid_t mpid = 0; mpid < (ssize_t)mpu_num_entries(); mpid++) {
cpu()->arch.profile.mpu.order.node[mpid].mpid = mpid;

if (mpu_entry_valid(mpid)) {
Expand Down
2 changes: 1 addition & 1 deletion src/arch/armv8/vgicv3.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool vgic_int_has_other_target(struct vcpu* vcpu, struct vgic_int* interrupt)
bool priv = gic_is_priv(interrupt->id);
bool routed_here =
!priv && !(interrupt->phys.route ^ (sysreg_mpidr_el1_read() & MPIDR_AFF_MSK));
bool route_valid = interrupt->phys.route != GICD_IROUTER_INV;
bool route_valid = interrupt->phys.route != (unsigned int)GICD_IROUTER_INV;
bool any = !priv && vgic_broadcast(vcpu, interrupt);
return any || (!routed_here && route_valid);
}
Expand Down
2 changes: 1 addition & 1 deletion src/arch/riscv/irqc/aia/vaplic.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static void vaplic_update_hart(struct vcpu* vcpu, int16_t vhart_index)
for (size_t i = 0; i < vaplic->idc_num; i++) {
vaplic_update_hart_line(vcpu, (vcpuid_t)i);
}
} else if (vhart_index < vaplic->idc_num) {
} else if ((uint16_t)vhart_index < vaplic->idc_num) {
vaplic_update_hart_line(vcpu, (vcpuid_t)vhart_index);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/arch/riscv/irqc/plic/vplic.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static int vplic_vcntxt_to_pcntxt(struct vcpu* vcpu, int vcntxt_id)
static bool vplic_vcntxt_valid(struct vcpu* vcpu, int vcntxt_id)
{
struct plic_cntxt vcntxt = plic_plat_id_to_cntxt(vcntxt_id);
return vcntxt_id < vcpu->vm->arch.vplic.cntxt_num && vcntxt.mode <= PRIV_S;
return (unsigned int)vcntxt_id < vcpu->vm->arch.vplic.cntxt_num && vcntxt.mode <= PRIV_S;
}

static bool vplic_get_pend(struct vcpu* vcpu, irqid_t id)
Expand Down
2 changes: 1 addition & 1 deletion src/arch/riscv/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static inline void as_map_physical_identity(struct addr_space* as)
size_t num_entries = ((top - base - 1) / lvl_size) + 1;

paddr_t addr = base;
for (int j = 0; j < num_entries; j++) {
for (unsigned int j = 0; j < num_entries; j++) {
int index = pt_getpteindex_by_va(&as->pt, (vaddr_t)addr, lvl);
pte_set(&pt[index], addr, PTE_SUPERPAGE, PTE_HYP_FLAGS);
addr += lvl_size;
Expand Down
10 changes: 5 additions & 5 deletions src/lib/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ ssize_t bitmap_find_nth(bitmap_t* map, size_t size, size_t nth, size_t start, bo
size_t count = 0;
unsigned bit = set ? 1 : 0;

for (ssize_t i = start; i < size; i++) {
for (size_t i = start; i < size; i++) {
if (bitmap_get(map, i) == bit) {
if (++count == nth) {
return i;
return (ssize_t)i;
}
}
}
Expand Down Expand Up @@ -69,10 +69,10 @@ ssize_t bitmap_find_consec(bitmap_t* map, size_t size, size_t start, size_t n, b
return -1;
}

while (i < size) {
while (i < (ssize_t)size) {
// find the last (with n as maximum) contiguous set page
count = bitmap_count_consecutive(map, size, i, n);
if (count < n) { // if didn't found enough n contiguous set pages
if (count < (ssize_t)n) { // if didn't found enough n contiguous set pages
i += count;
// find the last contiguous ~set page
i += bitmap_count_consecutive(map, size, i, -1);
Expand All @@ -81,7 +81,7 @@ ssize_t bitmap_find_consec(bitmap_t* map, size_t size, size_t start, size_t n, b
}
}

if (i >= size) {
if (i >= (ssize_t)size) {
i = -1;
}

Expand Down

0 comments on commit 3cbb083

Please sign in to comment.