Mesa (master): mesa: Check return value of __get_cpuid().

Matt Turner mattst88 at kemper.freedesktop.org
Sat Feb 28 20:20:45 UTC 2015


Module: Mesa
Branch: master
Commit: e71a7f8013e540281d17a0aa1aaa3a3051592ac8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e71a7f8013e540281d17a0aa1aaa3a3051592ac8

Author: Matt Turner <mattst88 at gmail.com>
Date:   Sat Feb 28 10:06:26 2015 -0800

mesa: Check return value of __get_cpuid().

The use of the uninitialized_var() macro was to silence an uninitialized
variable warning that I assumed stemmed from gcc being unable to see
inside __get_cpuid() or understand its inline assembly.

In fact, it was because the __get_cpuid() function can fail, and not
initialize its arguments. Instead, check for failure and return early.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/x86/common_x86.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/x86/common_x86.c b/src/mesa/x86/common_x86.c
index 25f5c40..14b497d 100644
--- a/src/mesa/x86/common_x86.c
+++ b/src/mesa/x86/common_x86.c
@@ -344,13 +344,13 @@ _mesa_get_x86_features(void)
 
 #elif defined(USE_X86_64_ASM)
    {
-      unsigned int uninitialized_var(eax), uninitialized_var(ebx),
-                   uninitialized_var(ecx), uninitialized_var(edx);
+      unsigned int eax, ebx, ecx, edx;
 
       /* Always available on x86-64. */
       _mesa_x86_cpu_features |= X86_FEATURE_XMM | X86_FEATURE_XMM2;
 
-      __get_cpuid(1, &eax, &ebx, &ecx, &edx);
+      if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx))
+         return;
 
       if (ecx & bit_SSE4_1)
          _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1;




More information about the mesa-commit mailing list