|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 09/12] xen/arm: guest_walk: Avoid theoritical unitialized value in get_top_bit
On Wed, 27 Mar 2019, Julien Grall wrote:
> 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@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> ---
> xen/arch/arm/guest_walk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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)) )
> --
> 2.11.0
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |