From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965967AbcBDS7d (ORCPT ); Thu, 4 Feb 2016 13:59:33 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41274 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965422AbcBDS7c (ORCPT ); Thu, 4 Feb 2016 13:59:32 -0500 Date: Thu, 4 Feb 2016 10:59:31 -0800 From: Andrew Morton To: Arnd Bergmann Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , open list , Bob Peterson Subject: Re: [PATCH v3] err.h: allow IS_ERR_VALUE to handle properly more types Message-Id: <20160204105931.7422c17d0bd1b92a387d97c9@linux-foundation.org> In-Reply-To: <13351313.c4ZqBbQEld@wuerfel> References: <20160202163350.f7d42f4b97f48756f3900e9a@linux-foundation.org> <1454505328-26019-1-git-send-email-a.hajda@samsung.com> <13351313.c4ZqBbQEld@wuerfel> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 04 Feb 2016 13:40:38 +0100 Arnd Bergmann wrote: > diff --git a/include/linux/err.h b/include/linux/err.h > index b7d4a9ff6342..bd4936a2c352 100644 > --- a/include/linux/err.h > +++ b/include/linux/err.h > @@ -18,9 +18,7 @@ > > #ifndef __ASSEMBLY__ > > -#define IS_ERR_VALUE(x) ((typeof(x))(-1) <= 0 \ > - ? unlikely((x) <= -1) \ > - : unlikely((x) >= (typeof(x))-MAX_ERRNO)) > +#define IS_ERR_VALUE(x) (unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO)) > > static inline void * __must_check ERR_PTR(long error) > { > > > I'm not sure if the cast to 'unsigned long long' might cause less > efficient code to be generated by gcc. I would hope that it is smart > enough to not actually extend shorter variables to 64 bit before > doing the comparison but I have not checked yet. I did a quick test with i386 on drivers/nvmem/core.o. The patch takes the text size from 9098 bytes to 9133. That file has 11 instances of IS_ERR_VALUE().