]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
x86: flip polarity of check_fast_pclmul
authorDaiki Ueno <ueno@gnu.org>
Tue, 9 Mar 2021 19:29:37 +0000 (20:29 +0100)
committerDaiki Ueno <ueno@gnu.org>
Wed, 10 Mar 2021 03:24:04 +0000 (04:24 +0100)
Otherwise GCC produces the following warnings as the stub
__get_cpuid() is defined as '#define __get_cpuid(...) 0':

x86-common.c: In function 'register_x86_crypto':
x86-common.c:314:15: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
  314 |  family = ((a >> 8) & 0x0F);
      |            ~~~^~~~~
x86-common.c:308:15: note: 'a' was declared here
  308 |  unsigned int a,b,c,d;
      |               ^

Signed-off-by: Daiki Ueno <ueno@gnu.org>
lib/accelerated/x86/x86-common.c

index ea4f0238b6cff5f905089fdfdc7eee26b8b650ca..80d37f49d54dced98d41f727021f61ab450a20f0 100644 (file)
@@ -308,14 +308,14 @@ static int check_fast_pclmul(void)
        unsigned int a,b,c,d;
        unsigned int family,model;
 
-       if (__get_cpuid(1, &a, &b, &c, &d))
+       if (!__get_cpuid(1, &a, &b, &c, &d))
                return 0;
 
        family = ((a >> 8) & 0x0F);
        model = ((a >> 4) & 0x0F) + ((a >> 12) & 0xF0);
 
-       if(((family == 0x6) && (model == 0xf || model == 0x19)) ||
-               ((family == 0x7) && (model == 0x1B || model == 0x3B)))
+       if (((family == 0x6) && (model == 0xf || model == 0x19)) ||
+           ((family == 0x7) && (model == 0x1B || model == 0x3B)))
                return 1;
        else
                return 0;
@@ -584,7 +584,7 @@ void register_x86_padlock_crypto(unsigned capabilities)
                        /* register GCM ciphers */
                        _gnutls_debug_log
                                ("Zhaoxin GCM accelerator was detected\n");
-                       if (check_avx_movbe() && !check_fast_pclmul()) {
+                       if (check_avx_movbe() && check_fast_pclmul()) {
                                _gnutls_debug_log
                                    ("Zhaoxin GCM accelerator (AVX) was detected\n");
                                ret =