stylistically, IS_ERR() versus IS_ERR_VALUE()?
Robert P. J. Day
rpjday at crashcourse.ca
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
14048
$
$ git grep -w IS_ERR_VALUE -- drivers | wc -l
48
$
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
drivers/net/ethernet/freescale/ucc_geth.c.
is there any non-obvious reason for driver code to use the latter?
superficially, they *seem* to be equivalent, but i've been surprised
before.
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca/dokuwiki
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
More information about the Kernelnewbies
mailing list