From: "Randy.Dunlap" <rdunlap@xenotime.net>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: Cong WANG <xiyou.wangcong@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: Style Question
Date: Sun, 11 Mar 2007 23:18:55 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.58.0703112318240.30187@shark.he.net> (raw)
In-Reply-To: <Pine.LNX.4.61.0703120638030.4339@yvahk01.tjqt.qr>
On Mon, 12 Mar 2007, Jan Engelhardt wrote:
>
> On Mar 12 2007 13:37, Cong WANG wrote:
> >
> > The following code is picked from drivers/kvm/kvm_main.c:
> >
> > static struct kvm_vcpu *vcpu_load(struct kvm *kvm, int vcpu_slot)
> > {
> > struct kvm_vcpu *vcpu = &kvm->vcpus[vcpu_slot];
> >
> > mutex_lock(&vcpu->mutex);
> > if (unlikely(!vcpu->vmcs)) {
> > mutex_unlock(&vcpu->mutex);
> > return 0;
> > }
> > return kvm_arch_ops->vcpu_load(vcpu);
> > }
> >
> > Obviously, it used 0 rather than NULL when returning a pointer to
> > indicate an error. Should we fix such issue?
>
> Indeed. If it was for me, something like that should throw a compile error.
At least it does throw a sparse warning, and yes, it should
be fixed.
> >>[...]
> > I think it's more clear to indicate we are using a pointer rather than
> > an integer when we use NULL in kernel. But in userspace, using NULL is
> > for portbility of the program, although most (*just* most, NOT all) of
> > NULL's defination is ((void*)0). ;-)
>
> NULL has the same bit pattern as the number zero. (I'm not saying the bit
> pattern is all zeroes. And I am not even sure if NULL ought to have the same
> pattern as zero.) So C++ could use (void *)0, if it would let itself :p
>
>
> >
> >
>
> Jan
>
--
~Randy
next prev parent reply other threads:[~2007-03-12 6:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-11 14:15 Cong WANG
2007-03-11 14:22 ` Bernd Petrovitsch
2007-03-11 20:35 ` Jan Engelhardt
2007-03-11 20:41 ` Daniel Hazelton
2007-03-11 22:01 ` Kyle Moffett
2007-03-11 23:16 ` Jan Engelhardt
2007-03-12 1:27 ` Kyle Moffett
2007-03-12 1:32 ` Jan Engelhardt
2007-03-12 1:43 ` Kyle Moffett
2007-03-12 5:37 ` Cong WANG
2007-03-12 5:40 ` Jan Engelhardt
2007-03-12 5:52 ` Nicholas Miell
2007-03-12 6:18 ` Randy.Dunlap [this message]
[not found] ` <MDEHLPKNGKAHNMBLJOLKOEBCCDAC.davids@webmaster.com>
2007-03-12 13:52 ` Cong WANG
[not found] <fa.Da+t1e9MgP7HaKS+dOWXVD8aYNI@ifi.uio.no>
2007-03-11 15:47 ` Robert Hancock
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.58.0703112318240.30187@shark.he.net \
--to=rdunlap@xenotime.net \
--cc=jengelh@linux01.gwdg.de \
--cc=linux-kernel@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/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®