From patchwork Wed Feb 6 21:37:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 31336 Received: (qmail 76474 invoked by alias); 6 Feb 2019 21:37:27 -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 76464 invoked by uid 89); 6 Feb 2019 21:37:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=shipped X-HELO: relay1.mentorg.com Date: Wed, 6 Feb 2019 21:37:20 +0000 From: Joseph Myers To: Subject: Avoid some left-shifts of negative constants Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 One group of warnings seen with -Wextra is "left shift of negative value [-Wshift-negative-value]". These may be hard to eliminate completely (some of them involve constants whose type ends up given by a typedef name, rather than simply int), but it still seems worth cleaning them up in other cases. This patch changes two places that trigger this warning to shift -1U instead of -1. Tested for x86_64. 2019-02-06 Joseph Myers * sysdeps/x86/cacheinfo.c (init_cacheinfo): Left-shift -1U instead of -1. diff --git a/sysdeps/x86/cacheinfo.c b/sysdeps/x86/cacheinfo.c index 02c886c9cd..c179c533a5 100644 --- a/sysdeps/x86/cacheinfo.c +++ b/sysdeps/x86/cacheinfo.c @@ -619,7 +619,7 @@ init_cacheinfo (void) /* Compute count mask. */ asm ("bsr %1, %0" : "=r" (count_mask) : "g" (threads_l2)); - count_mask = ~(-1 << (count_mask + 1)); + count_mask = ~(-1U << (count_mask + 1)); threads_l2 = (shipped - 1) & count_mask; count &= ~0x1; } @@ -636,7 +636,7 @@ init_cacheinfo (void) /* Compute count mask. */ asm ("bsr %1, %0" : "=r" (count_mask) : "g" (threads_core)); - count_mask = ~(-1 << (count_mask + 1)); + count_mask = ~(-1U << (count_mask + 1)); threads_core = (shipped - 1) & count_mask; if (level == 2) threads_l2 = threads_core;