kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Coding style quesion
@ 2016-06-18  8:44 Nicholas Mc Guire
  0 siblings, 0 replies; only message in thread
From: Nicholas Mc Guire @ 2016-06-18  8:44 UTC (permalink / raw)
  To: kernelnewbies


HI !

 Stumbled across the somewhat inconsistent treatement of functions returning ERR_PTR()
 in the kernel with respect to coding style, while trying to write some static code 
 checks. The two forms which seem comon are:

                if (PTR_ERR(var) == -EINVAL) {
 and
                if (var == ERR_PTR(-EINVAL)) {

 of which I think the first is the intended construct.

 my understanding of ERR_PTR is that it is intended to be used in the form

                ret = ERR_PTR(-EINVAL);
                ...
                retrurn ret;
 or
                return ERR_PTR(-EINVAL);

 but not as in the second if() above - technically its the same thing
 Is there an "official" preference to the one or other form ? 

thx!
hofrat

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

only message in thread, other threads:[~2016-06-18  8:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-18  8:44 Coding style quesion Nicholas Mc Guire

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).