KVM: remove redundant NULL tests
PATCH 1/1 KVM: remove redundant NULL tests
kvm_get_exit_data() cannot return a NULL pointer.
--- arch/ia64/kvm/kvm_fw.c | 28 +++++++++++++--------------- 1 files changed, 13 insertions(+), 15 deletions(-)
arch/ia64/kvm/kvm_fw.c +13 -15
@@ -75,7 +75,7 @@ static void set_pal_result(struct kvm_vcpu *vcpu,struct exit_ctl_data *p; p =kvm_get_exit_data (vcpu); -if (p && p->exit_reason ==EXIT_REASON_PAL_CALL ) { +if (p->exit_reason ==EXIT_REASON_PAL_CALL ) { p->u.pal_data.ret = result;return ; }
@@ -87,7 +87,7 @@ static void set_sal_result(struct kvm_vcpu *vcpu,struct exit_ctl_data *p; p =kvm_get_exit_data (vcpu); -if (p && p->exit_reason ==EXIT_REASON_SAL_CALL ) { +if (p->exit_reason ==EXIT_REASON_SAL_CALL ) { p->u.sal_data.ret = result;return ; }
@@ -322,7 +322,7 @@ static u64 kvm_get_pal_call_index(struct kvm_vcpu *vcpu)struct exit_ctl_data *p; p =kvm_get_exit_data (vcpu); -if (p && (p->exit_reason ==EXIT_REASON_PAL_CALL )) +if (p->exit_reason ==EXIT_REASON_PAL_CALL ) index = p->u.pal_data.gr28;return index;
@@ -646,18 +646,16 @@ static void kvm_get_sal_call_data(struct kvm_vcpu *vcpu, u64 *in0, u64 *in1, p =kvm_get_exit_data (vcpu); -if (p) { -if (p->exit_reason ==EXIT_REASON_SAL_CALL ) { - *in0 = p->u.sal_data.in0; - *in1 = p->u.sal_data.in1; - *in2 = p->u.sal_data.in2; - *in3 = p->u.sal_data.in3; - *in4 = p->u.sal_data.in4; - *in5 = p->u.sal_data.in5; - *in6 = p->u.sal_data.in6; - *in7 = p->u.sal_data.in7; -return ; - } +if (p->exit_reason ==EXIT_REASON_SAL_CALL ) { + *in0 = p->u.sal_data.in0; + *in1 = p->u.sal_data.in1; + *in2 = p->u.sal_data.in2; + *in3 = p->u.sal_data.in3; + *in4 = p->u.sal_data.in4; + *in5 = p->u.sal_data.in5; + *in6 = p->u.sal_data.in6; + *in7 = p->u.sal_data.in7; +return ; } *in0 =0 ; }
Quoted 12 lines · Roel Kluin
kvm_get_exit_data()cannot return a NULL pointer.Signed-off-by Roel Kluin <[email protected]>--- arch/ia64/kvm/kvm_fw.c | 28 +++++++++++++--------------- 1 files changed, 13 insertions(+), 15 deletions(-)arch/ia64/kvm/kvm_fw.c +0
-0
arch/ia64/kvm/kvm_fw.c static void set_pal_result(struct kvm_vcpu *vcpu, · line 81
Quoted 8 lines
arch/ia64/kvm/kvm_fw.c +1
-1@@ -75,7 +75,7 @@ static void set_pal_result(struct kvm_vcpu *vcpu,struct exit_ctl_data *p; p =kvm_get_exit_data (vcpu); -if (p && p->exit_reason ==EXIT_REASON_PAL_CALL ) { +if (p->exit_reason ==EXIT_REASON_PAL_CALL ) { p->u.pal_data.ret = result;return ; }
[___etc___]
Clearly the original author thought that there was a path where kvm_exit_data could return a NULL pointer, was that ever possible?
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot
Quoted 23 lines · Bill Davidsen
Quoted 12 lines · Roel Kluin
kvm_get_exit_data()cannot return a NULL pointer.Signed-off-by Roel Kluin <[email protected]>--- arch/ia64/kvm/kvm_fw.c | 28 +++++++++++++--------------- 1 files changed, 13 insertions(+), 15 deletions(-)arch/ia64/kvm/kvm_fw.c +0
-0arch/ia64/kvm/kvm_fw.c static void set_pal_result(struct kvm_vcpu *vcpu, · line 81
Quoted 8 lines
arch/ia64/kvm/kvm_fw.c +1
-1@@ -75,7 +75,7 @@ static void set_pal_result(struct kvm_vcpu *vcpu,struct exit_ctl_data *p; p =kvm_get_exit_data (vcpu); -if (p && p->exit_reason =EXIT_REASON_PAL_CALL ) { +if (p->exit_reason =EXIT_REASON_PAL_CALL ) { p->u.pal_data.ret = result;return ; }[___etc___]
Quoted 2 lines
Clearly the original author thought that there was a path where
kvm_exit_datacould return a NULL pointer, was that ever possible?
Originally, we planed to allocate the exit_data dynamically, but considering some constrains, the exit_data is allocated statically, so the check for NULL is useless now. Xiantao
Avi Kivity
AppliedQuoted 2 lines · Roel Kluin
kvm_get_exit_data()cannot return a NULL pointer.
Applied, thanks.
Signature · 1 line
error compiling committee.c: too many arguments to function