From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Likely Subject: Re: [patch] of: check for IS_ERR() Date: Fri, 26 Feb 2010 09:11:46 -0700 Message-ID: References: <20100226094941.GE4912@bicker> <20100226.015420.66646406.davem@davemloft.net> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20100226.015420.66646406.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Errors-To: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org To: David Miller Cc: error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, jezz-kPcTzGkeZgAdnm+yROfE0A@public.gmane.org, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, afleming-KZfg59tc24xl57MIdRCFDg@public.gmane.org, jeremy.kerr-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org List-Id: devicetree@vger.kernel.org On Fri, Feb 26, 2010 at 2:54 AM, David Miller wrote: > From: Dan Carpenter > Date: Fri, 26 Feb 2010 12:49:41 +0300 > >> get_phy_device() can return an ERR_PTR() >> >> Signed-off-by: Dan Carpenter >> --- >> I don't have a cross compile environment set up so I can't even compile >> test this. =A0:/ =A0But err.h is included so it should be OK. > > It should return ERR_PTR() consistently. =A0Checking for both > NULL and ERR_PTR() is undesirable. Ugh. This is why I dislike the ERR_PTR() pattern so much. The compiler cannot do any type checking and it is implemented inconsistently. You have to go look at the calling function to find out what you're allowed to do with the return value. ie. which test do I use? (!ptr) or IS_ERR(ptr)? It would be better if ERR_PTR() returned a structure or a union. At least that way the compiler would yell at you if the an ERR_PTR was being returned. g. -- = Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.