From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751857AbbCUABT (ORCPT ); Fri, 20 Mar 2015 20:01:19 -0400 Received: from mail-bn1bon0148.outbound.protection.outlook.com ([157.56.111.148]:27132 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751107AbbCUABR (ORCPT ); Fri, 20 Mar 2015 20:01:17 -0400 Date: Fri, 20 Mar 2015 19:01:09 -0500 From: Scott Wood To: LEROY Christophe CC: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , , Subject: Re: powerpc32: fix warning from include/asm-generic/termios-base.h Message-ID: <20150321000109.GA24932@home.buserror.net> References: <20141205112025.330971A5D4F@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20141205112025.330971A5D4F@localhost.localdomain> User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [2601:2:5800:3f7:12bf:48ff:fe84:c9a0] X-ClientProxiedBy: BLUPR01CA038.prod.exchangelabs.com (25.160.23.28) To BN3PR03MB1478.namprd03.prod.outlook.com (25.163.35.141) Authentication-Results: c-s.fr; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1478; X-Microsoft-Antispam-PRVS: X-Forefront-Antispam-Report: BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(24454002)(51704005)(19580405001)(76176999)(54356999)(53416004)(83506001)(42186005)(122386002)(97756001)(62966003)(23726002)(77156002)(46102003)(86362001)(33656002)(50986999)(92566002)(2950100001)(110136001)(46406003)(50466002)(87976001)(47776003);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR03MB1478;H:home.buserror.net;FPR:;SPF:None;MLV:sfv;LANG:en; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:BN3PR03MB1478;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1478; X-Forefront-PRVS: 05220145DE X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2015 00:01:14.7813 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1478 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 05, 2014 at 12:20:25PM +0100, LEROY Christophe wrote: > When size is equal to 1, the test is always true so lets eliminate both 0 and 1 > at first. > > include/asm-generic/termios-base.h: In function 'user_termio_to_kernel_termios': > include/asm-generic/termios-base.h:35:2: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] > if (get_user(termios->c_line, &termio->c_line) < 0) > ^ > include/asm-generic/termios-base.h: In function 'kernel_termios_to_user_termio': > include/asm-generic/termios-base.h:57:6: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] > put_user(termios->c_line, &termio->c_line) < 0 || > ^ > > Signed-off-by: Christophe Leroy > --- > arch/powerpc/include/asm/uaccess.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h > index 9485b43..f3028d2 100644 > --- a/arch/powerpc/include/asm/uaccess.h > +++ b/arch/powerpc/include/asm/uaccess.h > @@ -54,7 +54,7 @@ > > #define __access_ok(addr, size, segment) \ > (((addr) <= (segment).seg) && \ > - (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr))))) > + (((size) <= 1) || (((size) - 1) <= ((segment).seg - (addr))))) Again, I don't think Linux enables this warning. What did you do to produce this? In any case, it's a bad warning that doesn't take macros into account, and the answer is not to make the code less clear by hiding the fact that zero is a special case. -Scott