All of lore.kernel.org
 help / color / mirror / Atom feed
* stylistically, IS_ERR() versus IS_ERR_VALUE()?
@ 2018-12-31 19:53 Robert P. J. Day
  0 siblings, 0 replies; only message in thread
From: Robert P. J. Day @ 2018-12-31 19:53 UTC (permalink / raw)
  To: Kernel Newbies


  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
========================================================================

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-31 19:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-31 19:53 stylistically, IS_ERR() versus IS_ERR_VALUE()? Robert P. J. Day

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.