Commit 603c4ba96be998a8dd7a6f9b23681c49acdf4b64

Authored by Phil Carmody
Committed by Linus Torvalds
1 parent 9385565e20

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 <ext-phil.2.carmody@nokia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 5 additions and 0 deletions Side-by-side Diff

... ... @@ -34,6 +34,11 @@
34 34 return IS_ERR_VALUE((unsigned long)ptr);
35 35 }
36 36  
  37 +static inline long IS_ERR_OR_NULL(const void *ptr)
  38 +{
  39 + return !ptr || IS_ERR_VALUE((unsigned long)ptr);
  40 +}
  41 +
37 42 /**
38 43 * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type
39 44 * @ptr: The pointer to cast.