Received: by 10.223.185.116 with SMTP id b49csp1493052wrg; Sun, 4 Mar 2018 03:14:06 -0800 (PST) X-Google-Smtp-Source: AG47ELt7ExZxXVe/cl9vUMyajOMtbRRcTp2rSCXRB65Ci5yDI42wrczjYo/OxI+yfV9+DIaFLeWK X-Received: by 10.101.83.199 with SMTP id z7mr9607927pgr.105.1520162046286; Sun, 04 Mar 2018 03:14:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520162046; cv=none; d=google.com; s=arc-20160816; b=05UhNc3CWOyjhFVF4EruonN9EY5Aathmznn+gEvC7ibv9GX6Yh5U2M3umP+QQXQkbT +E02ChwW7JRQh0mWtqb4re++eUejADIj8TkoZRwQCdHv9ZNSWhSz4kA8ix/Jn2Uc7C9w 64Y5KtlFAOTy+Y9JXXQDkbEZsmfp6QRFhghDPf7wqn+0d//SB0lKjBPDYTexKFPv5+VI X6sWlDENMIEk72eY+5AR6iJ3xDlmQydPE8K76niYPEkYq4PrPjmhPsktDXJJc19ASQvI fm+1Opn/LoPAwU1C7R78t33HtDoR/4App82h9KiyJWM0pFfQzMmHobsVDJwHl+etgyV+ jf7Q== 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:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :arc-authentication-results; bh=glKNcyAHhV9+k6F10McQhEoM78t30cFJ8WiG1ROztgg=; b=ZEjIyELhB6OcS5NvwMa9CP2HaQV0fQkEGFMx2EkDzYERG6TxWtPKiD9bdxU9m2OyQ/ F3jaNYZ/paQXzHVddSD+GMt4UEAsGEJJTL1mUZUvJQhuRqU6o2rairsWmpEKguZ/OPur 8WQAyEG1IQarPzUTknVvu3VKKxNQgOuABycpdE+kai8JXKoD/Ik51gPvVx2g8/QNdKe8 wPjRlfI9k+6Xa1F5jQnPv8ekAdNwH/HK0JwDgCAGjZwIXxyGG/BLoXfldXBSceOQocpr AlzDOw098gFfoRuSztdjPcs31VuLfHifTg9q3qJM0K4h80VsfN8gQK9kKzuhNbwFdeUU dR8Q== 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 w20-v6si7460188plp.638.2018.03.04.03.13.52; Sun, 04 Mar 2018 03:14:06 -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 S1752681AbeCDKzW convert rfc822-to-8bit (ORCPT + 99 others); Sun, 4 Mar 2018 05:55:22 -0500 Received: from ozlabs.org ([103.22.144.67]:55727 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932292AbeCDKzV (ORCPT ); Sun, 4 Mar 2018 05:55:21 -0500 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 3zvKgq2kxxz9s25; Sun, 4 Mar 2018 21:55:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Mathieu Malaterre Cc: Benjamin Herrenschmidt , Paul Mackerras , Jiri Slaby , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Mathieu Malaterre Subject: Re: [PATCH 05/21] powerpc: Avoid comparison of unsigned long >= 0 in pfn_valid In-Reply-To: <20180225172236.29650-6-malat@debian.org> References: <20180225172236.29650-1-malat@debian.org> <20180225172236.29650-6-malat@debian.org> Date: Sun, 04 Mar 2018 21:55:17 +1100 Message-ID: <87lgf8gley.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Mathieu Malaterre writes: > Rewrite comparison since all values compared are of type `unsigned long`. > > Fix a warning (treated as error in W=1): > > CC arch/powerpc/kernel/irq.o > In file included from ./include/linux/bug.h:5:0, > from ./include/linux/cpumask.h:13, > from ./include/linux/smp.h:13, > from ./include/linux/kernel_stat.h:5, > from arch/powerpc/kernel/irq.c:35: > ./include/linux/dma-mapping.h: In function ‘dma_map_resource’: > ./arch/powerpc/include/asm/page.h:129:32: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits] > #define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < max_mapnr) > ^ > Suggested-by: Segher Boessenkool > Signed-off-by: Mathieu Malaterre > --- > arch/powerpc/include/asm/page.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h > index 8da5d4c1cab2..19dea64e7ed2 100644 > --- a/arch/powerpc/include/asm/page.h > +++ b/arch/powerpc/include/asm/page.h > @@ -126,7 +126,8 @@ extern long long virt_phys_offset; > > #ifdef CONFIG_FLATMEM > #define ARCH_PFN_OFFSET ((unsigned long)(MEMORY_START >> PAGE_SHIFT)) > -#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < max_mapnr) > +#define pfn_valid(pfn) \ > + (((pfn) - ARCH_PFN_OFFSET) < (max_mapnr - ARCH_PFN_OFFSET)) I'm not a big fan of this one, because the original code is *far* more obvious as to what it's doing. I'm not sure if we can make this one a static inline, or whether that would help, but it would be worth investigating. cheers