Received: by 10.223.185.116 with SMTP id b49csp4279026wrg; Mon, 26 Feb 2018 14:38:44 -0800 (PST) X-Google-Smtp-Source: AH8x226OgdTn21QCEIORVMDjrBK5pM4Rl9Y74W7uAg0qiloBlnBo74/ioi3KzGh7iNYe5AR4v/Lz X-Received: by 10.99.145.199 with SMTP id l190mr9293047pge.397.1519684724360; Mon, 26 Feb 2018 14:38:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519684724; cv=none; d=google.com; s=arc-20160816; b=jz4BFmmDlxYfWZRFLpSA/1J0noydlfJ69SStmTQYRiFMnSUlqUzbK+xIoiWl6ti9bH J7y6QnmXtaqHw8eZkKfMZivSESQWtXH2lNERMihyx5L39dUG6XOPSd9cYD2fVTqneE4j 9YjXp/ZQEGDLqlE9HkLO3HuIZLGf3Z8K92QftXO3CVtik87s8Jf9uANWTkwPCOHhoI8f QiKbRaV8fqcOgFme3VOeCxmVo3HWq1GXxPk2R3fT22WklLdZ95ozE5lpACKS+9s3Crh0 C95SAHBIr4Hnb3Ewgc+5x9YnskK9TluMfJA1XHQcD5+EVPcnRhqiUoI8I+c0yJgXJAYR 9kNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=/jEi8fXswIoYZ5VnTVIKt6Q5xcl3A+4fRvZcWXg8TDI=; b=XLUhUx34gvDobQHgPMxnFFy+YeFijpqAI5VjH3su8ih8erx4FBK1816yOSMMBlfBqT yiMFgkitVF9vpwfPwCN3MDhhVJEmM3lWebwBNNeCjLgo3v73v8+cuHXiSM9qOMTyu3a9 n2KLK6Kd9WUSHqay6Y9ggqqbupZeh8tM6BKSd3b7iiXLwRCPwM6phrww2O+YqnMQkC/j 4sX4+s1r/pMSYpvEUrZshK/dO5p1bXbO9uv9I4xKE8epTTdl7fWzAE4dt++GS9ig44Hn heX9kn12ncGOsMX5DjRHdiAagArMQ+aBLeeELmyPsJN11Ji/Fka4YePQ9VPTh3/8lnv8 WBQg== 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 n18si7423572pfj.58.2018.02.26.14.38.26; Mon, 26 Feb 2018 14:38:44 -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 S1751521AbeBZWS0 (ORCPT + 99 others); Mon, 26 Feb 2018 17:18:26 -0500 Received: from gate.crashing.org ([63.228.1.57]:60989 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750877AbeBZWSZ (ORCPT ); Mon, 26 Feb 2018 17:18:25 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id w1QMHofq020569; Mon, 26 Feb 2018 16:17:51 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id w1QMHmxJ020563; Mon, 26 Feb 2018 16:17:48 -0600 Date: Mon, 26 Feb 2018 16:17:48 -0600 From: Segher Boessenkool To: christophe leroy Cc: Mathieu Malaterre , Michael Ellerman , LKML , Paul Mackerras , Jiri Slaby , linuxppc-dev Subject: Re: [PATCH 06/21] powerpc: Avoid comparison of unsigned long >= 0 in __access_ok Message-ID: <20180226221747.GV21977@gate.crashing.org> References: <20180225172236.29650-1-malat@debian.org> <20180225172236.29650-7-malat@debian.org> <8862c1e1-d161-3410-1b2a-502ad06cef57@c-s.fr> <6cba215c-127e-f3eb-b525-773b6aed0eb7@c-s.fr> <4ddba8bc-b1e5-24a0-602e-672e7b51b203@c-s.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4ddba8bc-b1e5-24a0-602e-672e7b51b203@c-s.fr> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 26, 2018 at 09:00:09PM +0100, christophe leroy wrote: > Le 26/02/2018 ? 18:50, Mathieu Malaterre a ?crit?: > >On Mon, Feb 26, 2018 at 8:44 AM, Mathieu Malaterre > >wrote: > >>On Mon, Feb 26, 2018 at 7:50 AM, Christophe LEROY > >> wrote: > >>>Note that I already try to submit a fix for this warning 3 years ago > >>>(https://patchwork.ozlabs.org/patch/418075/) and it was rejected with the > >>>following comment: > > > >Tested again today with gcc 6.3.0 and gcc is still producing the > >original warning (treated as error). > > That's right, it seems that recent versions of gcc are not happy anymore > with that change. > > Maybe Segher has a suggestion for that one ? Your patch: #define __access_ok(addr, size, segment) \ (((addr) <= (segment).seg) && \ - (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr))))) + (((size) <= 1) || (((size) - 1) <= ((segment).seg - (addr))))) Is there any reason to write this as a macro? Let's make this more readable: static inline int __access_ok(unsigned long addr, unsigned long size, mm_segment_t seg) { if (addr > seg.seg) return 0; return (size == 0 || size - 1 <= seg.seg - addr); } and I think we are done already, or will this warn for any input? Segher