]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
aarch64: Fix undefined behavior in _dl_procinfo
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Fri, 9 Jun 2017 08:48:11 +0000 (14:18 +0530)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Fri, 9 Jun 2017 08:48:12 +0000 (14:18 +0530)
1 << 31 is undefined, so replace it with a cleaner check.  Also remove
magic numbers in comments.

* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h: Remove
mention of magic numbers in comments.
(_dl_procinfo): Fix undefined behavior

ChangeLog
sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h

index 6c6ff131db04a9a98997c22551fc0a901be07b6c..006e7ac28eeae19cf705f4e0b48e3466b3c50430 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-09  Siddhesh Poyarekar  <siddhesh@sourceware.org>
+
+       * sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h: Remove
+       mention of magic numbers in comments.
+       (_dl_procinfo): Fix undefined behavior
+
 2017-06-08  Joseph Myers  <joseph@codesourcery.com>
 
        * conform/data/sys/wait.h-data (WIFCONTINUED): Do not expect for
index cdb36d33166b37514b2f62599b82ac23a61d7669..04fc6be0a37c7b5fbd7944c2c8cb7b4e68b688eb 100644 (file)
@@ -40,7 +40,7 @@ _dl_procinfo (unsigned int type, unsigned long int word)
   _dl_printf ("AT_HWCAP:   ");
 
   for (i = 0; i < 32; ++i)
-    if (word & (1 << i))
+    if ((word >> i) & 1)
       _dl_printf (" %s", GLRO(dl_aarch64_cap_flags)[i]);
 
   _dl_printf ("\n");
@@ -56,10 +56,10 @@ _dl_hwcap_string (int idx)
 };
 
 
-/* 13 HWCAP bits set.  */
+/* Number of HWCAP bits set.  */
 #define _DL_HWCAP_COUNT 13
 
-/* Low 13 bits are allocated in HWCAP.  */
+/* Offset of the last bit allocated in HWCAP.  */
 #define _DL_HWCAP_LAST 12
 
 /* HWCAP_CPUID should be available by default to influence IFUNC as well as