]> xenbits.xensource.com Git - xen.git/commitdiff
libx86: Fix 32bit stubdom build of x86_cpuid_policy_fill_native()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 13 Nov 2018 11:58:47 +0000 (11:58 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 13 Nov 2018 13:32:46 +0000 (13:32 +0000)
With -m32, GCC generates a warning for &size_t == &unsigned long, which is the
typecheck hidden inside the min() macro.

Switch to using explicitly typed versions instead.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
xen/lib/x86/cpuid.c

index f09d8d57c1fb1a567ddabec86c59dfc0a1be780b..5a3159b3572be5761c1da73702eefdcbb156135a 100644 (file)
@@ -7,8 +7,8 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
     unsigned int i;
 
     cpuid_leaf(0, &p->basic.raw[0]);
-    for ( i = 1; i < min(ARRAY_SIZE(p->basic.raw),
-                         p->basic.max_leaf + 1ul); ++i )
+    for ( i = 1; i < min_t(unsigned int, ARRAY_SIZE(p->basic.raw),
+                           p->basic.max_leaf); ++i )
     {
         switch ( i )
         {
@@ -52,8 +52,8 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
     {
         cpuid_count_leaf(7, 0, &p->feat.raw[0]);
 
-        for ( i = 1; i < min(ARRAY_SIZE(p->feat.raw),
-                             p->feat.max_subleaf + 1ul); ++i )
+        for ( i = 1; i < min_t(unsigned int, ARRAY_SIZE(p->feat.raw),
+                               p->feat.max_subleaf); ++i )
             cpuid_count_leaf(7, i, &p->feat.raw[i]);
     }
 
@@ -96,7 +96,8 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
         xstates  = ((uint64_t)(p->xstate.xcr0_high | p->xstate.xss_high) << 32);
         xstates |=            (p->xstate.xcr0_low  | p->xstate.xss_low);
 
-        for ( i = 2; i < min(63ul, ARRAY_SIZE(p->xstate.raw)); ++i )
+        for ( i = 2; i < min_t(unsigned int, 63,
+                               ARRAY_SIZE(p->xstate.raw)); ++i )
         {
             if ( xstates & (1ul << i) )
                 cpuid_count_leaf(0xd, i, &p->xstate.raw[i]);
@@ -105,8 +106,8 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
 
     /* Extended leaves. */
     cpuid_leaf(0x80000000, &p->extd.raw[0]);
-    for ( i = 1; i < min(ARRAY_SIZE(p->extd.raw),
-                         p->extd.max_leaf + 1 - 0x80000000ul); ++i )
+    for ( i = 1; i < min_t(unsigned int, ARRAY_SIZE(p->extd.raw),
+                           p->extd.max_leaf + 1 - 0x80000000); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
 }