Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp429060imm; Thu, 28 Jun 2018 23:44:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfIZc3EiiVBXDifcPRnvj4V9yFJc3CPylIe2uy4vhCcATGQ8T3QwhRFq6yAZqL0m4GT6jig X-Received: by 2002:a62:bd03:: with SMTP id a3-v6mr13141999pff.138.1530254694160; Thu, 28 Jun 2018 23:44:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530254694; cv=none; d=google.com; s=arc-20160816; b=Gy2p56Xbxw+XYwXbtgE0HlGmYM5WKZqOquVBjBVd1fnbfzDuSc/rhlwsrY7kqKDhAw WpcYFSvtWqM3rXdp7Y1j9uP493L68Q3sx3AxHwB4yKW16ud5XUF7G+smjkKwB0/NKs2M AUxrguQPh7p7s6HZtoEl+7LF/kSK3QYez+FovdNYIJLfJyp6GGvK4phWnfYt4eHfSary r5HwjvQxrikQanIV1oZHReZ6txqWijtEGYs/LKn2rxhWwkPXACYMNJcoZU6sB1dnEKuR ggUF+YUKDo2RdmgF7lY+/UfzpSMjJvYJyWaOQYwJI6i3dCJIepSvD7MS9vJfIjFVneE8 0Jag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=W6LjoYi6hUPCgDrnXdsUZq0FDU8qfsvZlLXXN2mnLB0=; b=f0oYuAxONPEaYXTLc1eo6qdxufKoVYZLLzXEZqOB8bBUY/5RhEEu33TlwNNPmNm+LT PXhQ63XE/2oNBk8LDrLZh96UnU2SiP/tU+0sZEN+tVECvY2FyCQKgvP6aIfpUlq0rYFl I5Qhw1Sb7WMKtwTLD2vbZtkfnMXeab4ur/ejrSgK4d0SSVMK9zYwMDZdJkZn1dGBAle9 xkRjHA8rmY1j0TfzKuM0wbS1i2Z/p5hjqdE4QcQSS3MwZPLOX7JjWdoX/uw0lLJuYWdj byGHqpC/MK/TU0Q1V8k/LnjUMigVaYiG1nB7mEP9oiGJUgCFQniZLEn2k37BaP/QhODJ 6iFQ== 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 e3-v6si8169368pld.229.2018.06.28.23.44.40; Thu, 28 Jun 2018 23:44:54 -0700 (PDT) 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 S967657AbeF2Czm (ORCPT + 99 others); Thu, 28 Jun 2018 22:55:42 -0400 Received: from ozlabs.org ([203.11.71.1]:39223 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966362AbeF2Czl (ORCPT ); Thu, 28 Jun 2018 22:55:41 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 41H1VM6ClLz9s01; Fri, 29 Jun 2018 12:55:39 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , malat@debian.org, aneesh.kumar@linux.vnet.ibm.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH] powerpc/mm: fix always true/false warning in slice.c In-Reply-To: <63b696ab7be8b941fa1e1589f28260320d12a32a.1529589640.git.christophe.leroy@c-s.fr> References: <63b696ab7be8b941fa1e1589f28260320d12a32a.1529589640.git.christophe.leroy@c-s.fr> Date: Fri, 29 Jun 2018 12:55:39 +1000 Message-ID: <871scqwbbo.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe Leroy writes: > This patch fixes the following warnings (obtained with make W=1). > > arch/powerpc/mm/slice.c: In function 'slice_range_to_mask': > arch/powerpc/mm/slice.c:73:12: error: comparison is always true due to limited range of data type [-Werror=type-limits] > if (start < SLICE_LOW_TOP) { Presumably only on 32-bit ? > diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c > index 9530c6db406a..17c57760e06c 100644 > --- a/arch/powerpc/mm/slice.c > +++ b/arch/powerpc/mm/slice.c > @@ -79,7 +86,7 @@ static void slice_range_to_mask(unsigned long start, unsigned long len, > - (1u << GET_LOW_SLICE_INDEX(start)); > } > > - if ((start + len) > SLICE_LOW_TOP) { > + if (!slice_addr_is_low(end)) { > unsigned long start_index = GET_HIGH_SLICE_INDEX(start); > unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT)); > unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index; This worries me. By casting before the comparison in the helper you squash the compiler warning, but the code is still broken if (start + len) overflows. Presumably that "never happens", but it just seems fishy. The other similar check in that file does: if (SLICE_NUM_HIGH && ((start + len) > SLICE_LOW_TOP)) { Where SLICE_NUM_HIGH == 0 on 32-bit. Could we fix the less than comparisons with SLICE_LOW_TOP with something similar, eg: if (!SLICE_NUM_HIGH || start < SLICE_LOW_TOP) { ie. limit them to the 64-bit code? cheers