From: Al Viro <viro@ZenIV.linux.org.uk>
To: Julia Lawall <julia@diku.dk>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: ERR_PTR and PTR_ERR
Date: Sun, 16 May 2010 18:37:29 +0100 [thread overview]
Message-ID: <20100516173729.GE31073@ZenIV.linux.org.uk> (raw)
In-Reply-To: <Pine.LNX.4.64.1005161104520.6573@ask.diku.dk>
On Sun, May 16, 2010 at 11:05:23AM +0200, Julia Lawall wrote:
> On Sun, 16 May 2010, Julia Lawall wrote:
>
> > I see a number of occurrences of code like the following:
> >
> > if (IS_ERR(alg))
> > return ERR_PTR(PTR_ERR(alg));
> >
> > Is there any reason why the second line couldn't just be return alg?
>
> Hmm, never mind. It seems to address a type problem.
More idiomatic way to deal with that is ERR_CAST(); see e.g. ext2_lookup() for
use case:
...
inode = NULL;
if (ino) {
inode = ext2_iget(dir->i_sb, ino);
if (unlikely(IS_ERR(inode))) {
if (PTR_ERR(inode) == -ESTALE) {
ext2_error(dir->i_sb, __func__,
"deleted inode referenced: %lu",
(unsigned long) ino);
return ERR_PTR(-EIO);
} else {
return ERR_CAST(inode);
}
}
}
return d_splice_alias(inode, dentry);
next prev parent reply other threads:[~2010-05-16 17:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-16 8:58 ERR_PTR and PTR_ERR Julia Lawall
2010-05-16 9:05 ` Julia Lawall
2010-05-16 17:37 ` Al Viro [this message]
2010-05-16 18:26 ` Julia Lawall
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=20100516173729.GE31073@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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