Re: [PATCH 1/2] hw/riscv/riscv-iommu: change 'depth' to int

2024-11-04 Thread Alistair Francis
On Mon, Nov 4, 2024 at 10:41 PM Daniel Henrique Barboza wrote: > > Coverity reports an unsigned overflow when doing: > > for (; depth-- > 0; ) { > > When depth = 0 inside riscv_iommu_ctx_fetch(). > > Building it with a recent GCC the code doesn't actually break with depth > = 0, i.e. the compa

[PATCH 1/2] hw/riscv/riscv-iommu: change 'depth' to int

2024-11-04 Thread Daniel Henrique Barboza
Coverity reports an unsigned overflow when doing: for (; depth-- > 0; ) { When depth = 0 inside riscv_iommu_ctx_fetch(). Building it with a recent GCC the code doesn't actually break with depth = 0, i.e. the comparison "0-- > 0" will exit the loop instead of proceeding, but 'depth' will ret