dev.c:74:2: warning: variable 'dev_map' is uninitialized when used here [-Wuninitialized]
dev_map &= !DEV_MAP_V0_MASK;
^~~
1 warning generated.
On closer inspection, there are several other serious errors:
'x &= !mask' makes no sense, and looks as if someone confused bitwise and
logcal not operators. Judging the uses of &= without a not operator, they
appears to be confused with |= as well.
dev_map, if it isn't elided fully by the compiler due to UB, will contain 1
bit of stack rubble, and zeros elsewhere. As the valid bit for UINT0 is
clear, the one bit of stack rubble doesn't alter hardware behaviour.
dev_base_low is set to 0, then has various things including
dev_bitmap_paddr, and-ed out. This means that hardware is loaded with 0
and doesn't point at DEV in the first place.
Rewrite the function entirely, using the comments as guidance.
Clang complains:
dev.c:74:2: warning: variable 'dev_map' is uninitialized when used here [-Wuninitialized] dev_map &= !DEV_MAP_V0_MASK; ^
~~ 1 warning generated.On closer inspection, there are several other serious errors:
'x &= !mask' makes no sense, and looks as if someone confused bitwise and logcal not operators. Judging the uses of &= without a not operator, they appears to be confused with |= as well.
dev_map, if it isn't elided fully by the compiler due to UB, will contain 1 bit of stack rubble, and zeros elsewhere. As the valid bit for UINT0 is clear, the one bit of stack rubble doesn't alter hardware behaviour.
dev_base_low is set to 0, then has various things including dev_bitmap_paddr, and-ed out. This means that hardware is loaded with 0 and doesn't point at DEV in the first place.
Rewrite the function entirely, using the comments as guidance.
Signed-off-by: Andrew Cooper andrew.cooper3@citrix.com