kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: Kernel Newbies <kernelnewbies@kernelnewbies.org>
Subject: stylistically, IS_ERR() versus IS_ERR_VALUE()?
Date: Mon, 31 Dec 2018 14:53:23 -0500 (EST)	[thread overview]
Message-ID: <alpine.LFD.2.21.1812310701470.12883@localhost.localdomain> (raw)


  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

                 reply	other threads:[~2018-12-31 19:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.21.1812310701470.12883@localhost.localdomain \
    --to=rpjday@crashcourse.ca \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).