From: Phil Carmody Date: Tue, 15 Dec 2009 02:00:29 +0000 (-0800) Subject: err.h: add helper function to simplify pointer error checking X-Git-Tag: v2.6.33-rc1~153 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=commitdiff_plain;h=603c4ba96be998a8dd7a6f9b23681c49acdf4b64 err.h: add helper function to simplify pointer error checking There are quite a few instances in the kernel of checks of pointers both against NULL and against the errno range, handling both cases identically. This additional helper function would simplify such code. [akpm@linux-foundation.org: build fix] Signed-off-by: Phil Carmody Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/include/linux/err.h b/include/linux/err.h index ec87f3142bf3..1b12642636c7 100644 --- a/include/linux/err.h +++ b/include/linux/err.h @@ -34,6 +34,11 @@ static inline long IS_ERR(const void *ptr) return IS_ERR_VALUE((unsigned long)ptr); } +static inline long IS_ERR_OR_NULL(const void *ptr) +{ + return !ptr || IS_ERR_VALUE((unsigned long)ptr); +} + /** * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type * @ptr: The pointer to cast.