From patchwork Fri Jun 9 08:56:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 20878 Received: (qmail 85427 invoked by alias); 9 Jun 2017 08:56:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 85404 invoked by uid 89); 9 Jun 2017 08:56:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_NEUTRAL, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: homiemail-a119.g.dreamhost.com Reply-To: siddhesh@sourceware.org Subject: Re: [PATCH 6/6] aarch64: Add hwcap string routines To: Szabolcs Nagy , libc-alpha@sourceware.org Cc: nd@arm.com, adhemerval.zanella@linaro.org, sellcey@cavium.com References: <1496347928-19432-1-git-send-email-siddhesh@sourceware.org> <1496347928-19432-7-git-send-email-siddhesh@sourceware.org> <59381944.7030505@arm.com> <2e00fcba-204b-47c7-af27-ac619775289a@sourceware.org> <593A5B3F.5040701@arm.com> From: Siddhesh Poyarekar Message-ID: Date: Fri, 9 Jun 2017 14:26:29 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <593A5B3F.5040701@arm.com> On Friday 09 June 2017 01:54 PM, Szabolcs Nagy wrote: > please fix the undefined behaviour you introduced. > > and remove the comments with magic numbers so > on hwcap update comments do not need changes. Done, I've pushed the attached patch as per your and Andreas' comments. Sorry I missed your comment about undefined behavior. Siddhesh From 6c85cc2852367ea2db91ff6a1fc0f6fc0653788d Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Fri, 9 Jun 2017 14:18:11 +0530 Subject: [PATCH] aarch64: Fix undefined behavior in _dl_procinfo 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 | 6 ++++++ sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c6ff13..006e7ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017-06-09 Siddhesh Poyarekar + + * 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 * conform/data/sys/wait.h-data (WIFCONTINUED): Do not expect for diff --git a/sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h b/sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h index cdb36d3..04fc6be 100644 --- a/sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h +++ b/sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h @@ -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 -- 2.7.4