stylistically, IS_ERR() versus IS_ERR_VALUE()?

Robert P. J. Day rpjday at
Mon Dec 31 14:53:23 EST 2018

  poking around error handling in the kernel, and noticed the
following ... in include/linux/err.h, we have IS_ERR() unsurprisingly
defined in terms of IS_ERR_VALUE():

  #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= \
    (unsigned long)-MAX_ERRNO)

  ... snip ...

  static inline bool __must_check IS_ERR(__force const void *ptr)
        return IS_ERR_VALUE((unsigned long)ptr);

fair enough, and the above suggests that it's technically equivalent
to use either one, but if i search under drivers/ for each:

  $ git grep -w IS_ERR -- drivers | wc -l

  $ git grep -w IS_ERR_VALUE -- drivers | wc -l

so IS_ERR() is pretty clearly the call of choice, and the invocations
of IS_ERR_VALUE() are concentrated in a small number of files -- heck,
15 of those calls are in the single file

  is there any non-obvious reason for driver code to use the latter?
superficially, they *seem* to be equivalent, but i've been surprised



Robert P. J. Day                                 Ottawa, Ontario, CANADA


More information about the Kernelnewbies mailing list