xen/arm: guest_walk: Avoid theoritical unitialized value in get_top_bit
authorJulien Grall <julien.grall@arm.com>
Wed, 27 Mar 2019 18:45:28 +0000 (18:45 +0000)
committerWei Liu <wei.liu2@citrix.com>
Mon, 13 May 2019 10:28:03 +0000 (11:28 +0100)
commitc451bc33ae0501a4f5cee928c90760233c0b2909
tree6e21d3edefd32754c1254d7c954b6ea5bc6c4159
parenta17138b0e7f12c9ba2ac538c017a55a4cf56d77f
xen/arm: guest_walk: Avoid theoritical unitialized value in get_top_bit

Clang 8.0 throws an error in the get_top_bit function:

guest_walk.c:328:15: error: variable 'topbit' is used uninitialized
whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
    else if ( is_64bit_domain(d) )
              ^~~~~~~~~~~~~~~~~~

This is happening because clang thinks that is_32bit_domain(d) is not
the exact inverse of is_64bit_domain(d). So it expects a else case to
handle the case where the latter call is false.

In other part of the code, dealing with difference between 32-bit and
64-bit domain, we usually use if ( is_XXbit_domain ) ... else ...

So use the same pattern here.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/guest_walk.c