Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6287891ybv; Wed, 12 Feb 2020 09:18:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyDGQ9x8LhGIkmmzfzdoieoSgdFfpKnRtPoGPaW6qSJlvl6oMM4nI7QOE0rh/gzjJFuAEEb X-Received: by 2002:aca:5ad5:: with SMTP id o204mr96943oib.2.1581527937843; Wed, 12 Feb 2020 09:18:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581527937; cv=none; d=google.com; s=arc-20160816; b=xl2ozGoOI1RFA0r3Z1/mER3u1u7DtIO4krvXx+9PDlS/QVqF5vX9O7duEUu5bI1rpT uj7cbT1zhASzUtOR+xv9Q2QmYMtYf/Fo84hhAR8w0kpZmhuwlwA4cTyunfxcIG1XqAqq X7eGacgJ1i0Zky9DyMWpnlWKBj0AAR9q8F+ZAh/fmZYY5rMFpXA8XAwdUxSEBb+VPv+C KQBpW0GXnzfdiYtVrggPjyMj2ADAM0DwMJ5ac0dXpCw+eW6ukOdnpPU0DHnwRYGSe7kH ryHt+87UE7tAF2HDHALAthsiBTvmCxP3JoTwzNg/fJ/J0OlKU8qJIMYYjaw9pk20LAyC p92w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=LJC1hqZoMvLofXefUc9ebaJYZfqEeMS3K8gi4YGYApw=; b=PfCVqnUP42X4P54XEfK0UhCYm3wMQNL8pvByeU/m7RIjzcwnrXp0ZuylBoL0nU+OHz 5JuUHRS0pyBGciQVjt7YRy5nTlkpz197vHHsPaH6dQbLzDjU9MTqiPwDe0FtEbFt8TSl cgyOB5hecEqMc+WxSyhcyd5V9NEQAHRPXjBcTynjM4hIUrjK9oNxc+ku16hNXChIIV10 eYOywa49XVOXPDJQxxPa0e3a0oY1mSDzY6pyFfk9Xpf+1K6g2f8Q4H9Eyz6YOor2j81l RDPe8vXlD+f9hTSK+N+As5YU1vjjy61CObp8wiKD4nlmD20FuYFNnGascmbfM8Huv3EI n3DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y205si3792826oig.137.2020.02.12.09.18.45; Wed, 12 Feb 2020 09:18:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727600AbgBLRRJ (ORCPT + 99 others); Wed, 12 Feb 2020 12:17:09 -0500 Received: from mail.netline.ch ([148.251.143.178]:59978 "EHLO netline-mail3.netline.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726982AbgBLRRJ (ORCPT ); Wed, 12 Feb 2020 12:17:09 -0500 Received: from localhost (localhost [127.0.0.1]) by netline-mail3.netline.ch (Postfix) with ESMTP id 514DB2A604B; Wed, 12 Feb 2020 18:17:06 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at netline-mail3.netline.ch Received: from netline-mail3.netline.ch ([127.0.0.1]) by localhost (netline-mail3.netline.ch [127.0.0.1]) (amavisd-new, port 10024) with LMTP id TidibmeR2N2o; Wed, 12 Feb 2020 18:17:06 +0100 (CET) Received: from thor (252.80.76.83.dynamic.wline.res.cust.swisscom.ch [83.76.80.252]) by netline-mail3.netline.ch (Postfix) with ESMTPSA id 01A9A2A6046; Wed, 12 Feb 2020 18:17:05 +0100 (CET) Received: from [::1] by thor with esmtp (Exim 4.93) (envelope-from ) id 1j1vdJ-000ow8-2f; Wed, 12 Feb 2020 18:17:05 +0100 Subject: Re: [PATCH v2] drm/i915: Disable -Wtautological-constant-out-of-range-compare To: Nathan Chancellor Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, dri-devel@lists.freedesktop.org, Rodrigo Vivi References: <20200211050808.29463-1-natechancellor@gmail.com> <20200211061338.23666-1-natechancellor@gmail.com> <4c806435-f32d-1559-9563-ffe3fa69f0d1@daenzer.net> <20200211203935.GA16176@ubuntu-m2-xlarge-x86> <20200212170734.GA16396@ubuntu-m2-xlarge-x86> From: =?UTF-8?Q?Michel_D=c3=a4nzer?= Message-ID: Date: Wed, 12 Feb 2020 18:17:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <20200212170734.GA16396@ubuntu-m2-xlarge-x86> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-02-12 6:07 p.m., Nathan Chancellor wrote: > On Wed, Feb 12, 2020 at 09:52:52AM +0100, Michel Dänzer wrote: >> On 2020-02-11 9:39 p.m., Nathan Chancellor wrote: >>> On Tue, Feb 11, 2020 at 10:41:48AM +0100, Michel Dänzer wrote: >>>> On 2020-02-11 7:13 a.m., Nathan Chancellor wrote: >>>>> A recent commit in clang added -Wtautological-compare to -Wall, which is >>>>> enabled for i915 so we see the following warning: >>>>> >>>>> ../drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:1485:22: warning: >>>>> result of comparison of constant 576460752303423487 with expression of >>>>> type 'unsigned int' is always false >>>>> [-Wtautological-constant-out-of-range-compare] >>>>> if (unlikely(remain > N_RELOC(ULONG_MAX))) >>>>> ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ >>>>> >>>>> This warning only happens on x86_64 but that check is relevant for >>>>> 32-bit x86 so we cannot remove it. >>>> >>>> That's suprising. AFAICT N_RELOC(ULONG_MAX) works out to the same value >>>> in both cases, and remain is a 32-bit value in both cases. How can it be >>>> larger than N_RELOC(ULONG_MAX) on 32-bit (but not on 64-bit)? >>>> >>> >>> Hi Michel, >>> >>> Can't this condition be true when UINT_MAX == ULONG_MAX? >> >> Oh, right, I think I was wrongly thinking long had 64 bits even on 32-bit. >> >> >> Anyway, this suggests a possible better solution: >> >> #if UINT_MAX == ULONG_MAX >> if (unlikely(remain > N_RELOC(ULONG_MAX))) >> return -EINVAL; >> #endif >> >> >> Or if that can't be used for some reason, something like >> >> if (unlikely((unsigned long)remain > N_RELOC(ULONG_MAX))) >> return -EINVAL; >> >> should silence the warning. > > I do like this one better than the former. FWIW, one downside of this one compared to all alternatives (presumably) is that it might end up generating actual code even on 64-bit, which always ends up skipping the return. -- Earthling Michel Dänzer | https://redhat.com Libre software enthusiast | Mesa and X developer