Re: Style Question

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Cong WANG
Date: Sunday, March 11, 2007 - 10:37 pm

2007/3/12, Jan Engelhardt <jengelh@linux01.gwdg.de>:

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?


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). ;-)
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Style Question, Cong WANG, (Sun Mar 11, 7:15 am)
Re: Style Question, Bernd Petrovitsch, (Sun Mar 11, 7:22 am)
Re: Style Question, Jan Engelhardt, (Sun Mar 11, 1:35 pm)
Re: Style Question, Daniel Hazelton, (Sun Mar 11, 1:41 pm)
Re: Style Question, Kyle Moffett, (Sun Mar 11, 3:01 pm)
Re: Style Question, Jan Engelhardt, (Sun Mar 11, 4:16 pm)
Re: Style Question, Kyle Moffett, (Sun Mar 11, 6:27 pm)
Re: Style Question, Jan Engelhardt, (Sun Mar 11, 6:32 pm)
Re: Style Question, Kyle Moffett, (Sun Mar 11, 6:43 pm)
Re: Style Question, Cong WANG, (Sun Mar 11, 10:37 pm)
Re: Style Question, Jan Engelhardt, (Sun Mar 11, 10:40 pm)
Re: Style Question, Nicholas Miell, (Sun Mar 11, 10:52 pm)
Re: Style Question, Randy.Dunlap, (Sun Mar 11, 11:18 pm)