[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging] xen/arm: guest_walk: Avoid theoritical unitialized value in get_top_bit



commit c451bc33ae0501a4f5cee928c90760233c0b2909
Author:     Julien Grall <julien.grall@xxxxxxx>
AuthorDate: Wed Mar 27 18:45:28 2019 +0000
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Mon May 13 11:28:03 2019 +0100

    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@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)) )
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.