Skip to contentSkip to conversation

cpuid: use unsigned for max cpuid

PATCH In review Michael S. Tsirkin 2 participants 2 messages Jan 25, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpuid: use unsigned for max cpuid

__get_cpuid_max returns an unsigned value.
For consistency, store the result in an unsigned variable.

Found by running ./configure --extra-cflags=-Wconversion

Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---

Richard, if appropriate pls queue this.
Thanks!

 configure                 | 2 +-
 util/bufferiszero.c       | 2 +-
 tcg/i386/tcg-target.c.inc | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
configure +1 -1
index e1a31fb332..938f43a59a 100755
@@ -2768,7 +2768,7 @@ cat > $TMPC << EOF
 #include <cpuid.h>
 int main(void) {
     unsigned a, b, c, d;
-    int max = __get_cpuid_max(0, 0);
+    unsigned max = __get_cpuid_max(0, 0);
 
     if (max >= 1) {
         __cpuid(1, a, b, c, d);
util/bufferiszero.c +1 -1
index 695bb4ce28..ec3cd4ca15 100644
@@ -272,7 +272,7 @@ static void init_accel(unsigned cache)
 
 static void __attribute__((constructor)) init_cpuid_cache(void)
 {
-    int max = __get_cpuid_max(0, NULL);
+    unsigned max = __get_cpuid_max(0, NULL);
     int a, b, c, d;
     unsigned cache = 0;
 
tcg/i386/tcg-target.c.inc +1 -1
index 875311f795..4dab09f265 100644
@@ -3747,7 +3747,7 @@ static void tcg_target_init(TCGContext *s)
 {
 #ifdef CONFIG_CPUID_H
     unsigned a, b, c, d, b7 = 0;
-    int max = __get_cpuid_max(0, 0);
+    unsigned max = __get_cpuid_max(0, 0);
 
     if (max >= 7) {
         /* BMI1 is available on AMD Piledriver and Intel Haswell CPUs.  */
Signature · 1 line
MST
Reviewed-by Philippe Mathieu-Daudé on v1 1/1
#1 lore raw
Quoted 10 lines · Michael S. Tsirkin

__get_cpuid_max returns an unsigned value.
For consistency, store the result in an unsigned variable.

Found by running ./configure --extra-cflags=-Wconversion

Cc Paolo Bonzini <[email protected]>
Cc Richard Henderson <[email protected]>

---

Quoted 7 lines

Richard, if appropriate pls queue this.
Thanks!

  configure                 | 2 +-
  util/bufferiszero.c       | 2 +-
  tcg/i386/tcg-target.c.inc | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)