[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4175803.I7CDUloLxQ@wuerfel>
Date: Tue, 26 Jul 2016 13:39:15 +0200
From: Arnd Bergmann <arnd@...db.de>
To: linuxppc-dev@...ts.ozlabs.org
Cc: Arvind Yadav <arvind.yadav.cs@...il.com>, zajec5@...il.com,
leoli@...escale.com, qiang.zhao@...escale.com,
viresh.kumar@...aro.org, linux-wireless@...r.kernel.org,
netdev@...r.kernel.org, scottwood@...escale.com,
akpm@...ux-foundation.org, linux@...ck-us.net
Subject: Re: [v3] UCC_GETH/UCC_FAST: Use IS_ERR_VALUE_U32 API to avoid IS_ERR_VALUE abuses.
On Saturday, July 23, 2016 11:35:51 PM CEST Arvind Yadav wrote:
> diff --git a/include/linux/err.h b/include/linux/err.h
> index 1e35588..a42f942 100644
> --- a/include/linux/err.h
> +++ b/include/linux/err.h
> @@ -19,6 +19,7 @@
> #ifndef __ASSEMBLY__
>
> #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
> +#define IS_ERR_VALUE_U32(x) unlikely((unsigned int)(x) >= (unsigned int)-MAX_ERRNO)
>
> static inline void * __must_check ERR_PTR(long error)
> {
This doesn't really look like something we want to have as a generic
interface. The IS_ERR_VALUE() API is rather awkward already, and your
use seems specific to the cpu_muram_alloc() function.
How about something like
int cpm_muram_error(unsigned long addr)
{
if (addr >= (unsigned long)-MAX_ERRNO)
return addr;
else
return 0;
}
and then use that to check the value returned by the allocation
that is still an 'unsigned long', before assigning it to a 'u32'.
Arnd
Powered by blists - more mailing lists