mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julia Lawall <julia@diku.dk>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: ERR_PTR and PTR_ERR
Date: Sun, 16 May 2010 20:26:31 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.1005162025560.12921@ask.diku.dk> (raw)
In-Reply-To: <20100516173729.GE31073@ZenIV.linux.org.uk>

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@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

      reply	other threads:[~2010-05-16 18:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-16  8:58 Julia Lawall
2010-05-16  9:05 ` Julia Lawall
2010-05-16 17:37   ` Al Viro
2010-05-16 18:26     ` Julia Lawall [this message]

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=Pine.LNX.4.64.1005162025560.12921@ask.diku.dk \
    --to=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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

all inboxes | Powered by JetHome®