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: 1037773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99837-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="f+rBMust"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43vvtR0KDKz9sNG for ; Thu, 7 Feb 2019 08:37:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=J+7HfboA9MKzrc2NUxUWq69+9vxcx BSNBih9MnZ9k0SHjWFgz7ikSJhkpIM4R8x7ip4cLCoUIY3ajecvM39NHOa4G9mFE XsImXPeDMg9Ptl43zZHQ+KseVmvztUvOfyeCacD+9xKE7c/MucJFMvN4t024sthT ixEOq30HZavwGE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=zLQnckX5UjD7ZzzZ7o8Ci+Hsrbw=; b=f+r BMustgXbft0t9zzGVUX69raFaPVsL6AVfbO5s21yJi28X0dYh2LT8cTHutgmFJ7W OcE4KVYGNk1HDtR/xaMO8pcTHNQIxz5WDmfzSIlDTL/tMwYZgEFpx2dXt04PsDvc y9b6Syrcjzu5FMuRcNMyakRVncPhE1MetkeH/btg= 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;