From: Julien Grall Date: Wed, 27 Mar 2019 18:45:28 +0000 (+0000) Subject: xen/arm: guest_walk: Avoid theoritical unitialized value in get_top_bit X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~2277 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c451bc33ae0501a4f5cee928c90760233c0b2909;p=xen.git 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 Reviewed-by: Stefano Stabellini --- diff --git a/xen/arch/arm/guest_walk.c b/xen/arch/arm/guest_walk.c index 7db7a7321b..1bee198777 100644 --- a/xen/arch/arm/guest_walk.c +++ b/xen/arch/arm/guest_walk.c @@ -325,7 +325,7 @@ static unsigned int get_top_bit(struct domain *d, vaddr_t gva, register_t tcr) */ if ( is_32bit_domain(d) ) topbit = 31; - else if ( is_64bit_domain(d) ) + else { if ( ((gva & BIT_ULL(55)) && (tcr & TCR_EL1_TBI1)) || (!(gva & BIT_ULL(55)) && (tcr & TCR_EL1_TBI0)) )