[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.1005162025560.12921@ask.diku.dk>
Date: Sun, 16 May 2010 20:26:31 +0200 (CEST)
From: Julia Lawall <julia@...u.dk>
To: Al Viro <viro@...IV.linux.org.uk>
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: ERR_PTR and PTR_ERR
On Sun, 16 May 2010, Al Viro wrote:
> 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:
Thanks. That looks much nicer than ERR_PTR(PTR_ERR(alg)).
julia
> ...
> 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);
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists