From: Rusty Russell <rusty@rustcorp.com.au>
To: Andru Gheorghiu <gheorghiuandru@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH] drivers: virtio: Use PTR_RET function
Date: Tue, 26 Mar 2013 20:53:27 +1030 [thread overview]
Message-ID: <87620ecvds.fsf@rustcorp.com.au> (raw)
In-Reply-To: <CADca43+r4kPBv-=kqo5VZ4+E2-OD1Y6ipkPXzxmFwrt2x1Z7Vw@mail.gmail.com>
Andru Gheorghiu <gheorghiuandru@gmail.com> writes:
> PTR_RET does return. It's perfectly equivalent to using IS_ERR and the
> returning PTR_ERR. The implementation is here [1].
Um, I read the implementation, thanks.
> The reason for using it is this: if you have a function that does
> something why not call it instead of reproducing it's behavior by
> explicitly writing what it does.
Because clarity matters, and this function makes callers less clear.
It's the most breathtakingly bad name since BUILD_BUG_ON_ZERO().
Why not change PTR_ERR to return 0 if !IS_ERR()? Noone breaks, gcc
probably produces the same code, and noone needs to learn your weird
new kernel meme.
In fact, as gcc will produce the same code for "if (PTR_ERR(p))" as it
does for "if (IS_ERR(p))", you get to be one of the very, very few
people who have ever *reduced* the complexity of a kernel interface.
Cheers,
Rusty.
next prev parent reply other threads:[~2013-03-26 10:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1364217936-6284-1-git-send-email-gheorghiuandru@gmail.com>
2013-03-26 3:27 ` [PATCH] drivers: virtio: Use PTR_RET function Rusty Russell
2013-03-26 5:01 ` Andrew Morton
2013-03-26 7:41 ` Andru Gheorghiu
2013-03-26 10:23 ` Rusty Russell [this message]
2013-03-25 13:25 Alexandru Gheorghiu
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=87620ecvds.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=akpm@linux-foundation.org \
--cc=gheorghiuandru@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=virtualization@lists.linux-foundation.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).