]> xenbits.xensource.com Git - xen.git/commitdiff
x86/PVH: Use unsigned int for dom0 e820 index
authorJason Andryuk <jason.andryuk@amd.com>
Mon, 22 Apr 2024 13:11:02 +0000 (15:11 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 22 Apr 2024 13:11:02 +0000 (15:11 +0200)
Switch to unsigned int for the dom0 e820 index.  This eliminates the
potential for array underflows, and the compiler might be able to
generate better code.

Requested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/dom0_build.c

index d158f4d241389c1c3bd28de764895c40345a199b..ac71d43a6b3fd83bb064ebf68265cad0d907e4ea 100644 (file)
@@ -569,7 +569,7 @@ static paddr_t __init find_kernel_memory(
 {
     paddr_t kernel_size = elf->dest_size;
     unsigned int align;
-    int i;
+    unsigned int i;
 
     if ( parms->phys_align != UNSET_ADDR32 )
         align = parms->phys_align;
@@ -579,7 +579,7 @@ static paddr_t __init find_kernel_memory(
         align = MB(2);
 
     /* Search backwards to find the highest address. */
-    for ( i = d->arch.nr_e820 - 1; i >= 0 ; i-- )
+    for ( i = d->arch.nr_e820; i--; )
     {
         paddr_t start = d->arch.e820[i].addr;
         paddr_t end = start + d->arch.e820[i].size;