From: SF Markus Elfring <elfring@users.sourceforge.net>
To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, "Alexander Graf" <agraf@suse.com>,
"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 05/11] KVM: PPC: Book3S HV: Adjust nine checks for null pointers
Date: Fri, 20 Jan 2017 19:23:59 +0100 [thread overview]
Message-ID: <161c8660-d204-5190-9bda-c5a801abe0ab@users.sourceforge.net> (raw)
In-Reply-To: <fc2c36e6-a453-ae09-89bf-98b3d74113a4@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 20 Jan 2017 11:25:48 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script "checkpatch.pl" pointed information out like the following.
Comparison to NULL could be written …
Thus fix affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/powerpc/kvm/book3s_hv.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index cfc7699d05df..3122998f6a32 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -458,7 +458,7 @@ static unsigned long do_h_register_vpa(struct kvm_vcpu *vcpu,
/* convert logical addr to kernel addr and read length */
va = kvmppc_pin_guest_page(kvm, vpa, &nb);
- if (va == NULL)
+ if (!va)
return H_PARAMETER;
if (subfunc == H_VPA_REG_VPA)
len = be16_to_cpu(((struct reg_vpa *)va)->length.hword);
@@ -1591,8 +1591,7 @@ static struct kvmppc_vcore *kvmppc_vcore_create(struct kvm *kvm, int core)
struct kvmppc_vcore *vcore;
vcore = kzalloc(sizeof(struct kvmppc_vcore), GFP_KERNEL);
-
- if (vcore == NULL)
+ if (!vcore)
return NULL;
spin_lock_init(&vcore->lock);
@@ -2221,7 +2220,7 @@ static void collect_piggybacks(struct core_info *cip, int target_threads)
prepare_threads(pvc);
if (!pvc->n_runnable) {
list_del_init(&pvc->preempt_list);
- if (pvc->runner == NULL) {
+ if (!pvc->runner) {
pvc->vcore_state = VCORE_INACTIVE;
kvmppc_core_end_stolen(pvc);
}
@@ -2287,7 +2286,7 @@ static void post_guest_process(struct kvmppc_vcore *vc, bool is_master)
} else {
vc->vcore_state = VCORE_INACTIVE;
}
- if (vc->n_runnable > 0 && vc->runner == NULL) {
+ if (vc->n_runnable > 0 && !vc->runner) {
/* make sure there's a candidate runner awake */
i = -1;
vcpu = next_runnable_thread(vc, &i);
@@ -2786,7 +2785,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
while (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE &&
!signal_pending(current)) {
- if (vc->vcore_state == VCORE_PREEMPT && vc->runner == NULL)
+ if (vc->vcore_state == VCORE_PREEMPT && !vc->runner)
kvmppc_vcore_end_preempt(vc);
if (vc->vcore_state != VCORE_INACTIVE) {
@@ -2833,7 +2832,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
vc->vcore_state == VCORE_PIGGYBACK))
kvmppc_wait_for_exec(vc, vcpu, TASK_UNINTERRUPTIBLE);
- if (vc->vcore_state == VCORE_PREEMPT && vc->runner == NULL)
+ if (vc->vcore_state == VCORE_PREEMPT && !vc->runner)
kvmppc_vcore_end_preempt(vc);
if (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE) {
@@ -3203,7 +3202,7 @@ void kvmppc_alloc_host_rm_ops(void)
int size;
/* Not the first time here ? */
- if (kvmppc_host_rm_ops_hv != NULL)
+ if (kvmppc_host_rm_ops_hv)
return;
ops = kzalloc(sizeof(struct kvmppc_host_rm_ops), GFP_KERNEL);
@@ -3430,10 +3429,10 @@ static int kvmppc_set_passthru_irq(struct kvm *kvm, int host_irq, int guest_gsi)
mutex_lock(&kvm->lock);
pimap = kvm->arch.pimap;
- if (pimap == NULL) {
+ if (!pimap) {
/* First call, allocate structure to hold IRQ map */
pimap = kvmppc_alloc_pimap();
- if (pimap == NULL) {
+ if (!pimap) {
mutex_unlock(&kvm->lock);
return -ENOMEM;
}
--
2.11.0
next prev parent reply other threads:[~2017-01-20 18:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 18:18 [PATCH 00/11] PowerPC-KVM: Fine-tuning for some function implementations SF Markus Elfring
2017-01-20 18:19 ` [PATCH 01/11] KVM: PPC: Book3S HV: Move assignments for the variable "err" in kvm_htab_write() SF Markus Elfring
2017-01-23 14:12 ` Paolo Bonzini
2017-01-20 18:20 ` [PATCH 02/11] KVM: PPC: Book3S HV: Improve a size determination in kvmppc_alloc_hpt() SF Markus Elfring
2017-01-20 18:21 ` [PATCH 03/11] KVM: PPC: Book3S HV: Move error code assignments in two functions SF Markus Elfring
2017-01-23 14:13 ` Paolo Bonzini
2017-01-20 18:22 ` [PATCH 04/11] KVM: PPC: Book3S HV: Use common error handling code in kvmppc_clr_passthru_irq() SF Markus Elfring
2017-01-20 18:23 ` SF Markus Elfring [this message]
2017-01-23 19:22 ` [PATCH 05/11] KVM: PPC: Book3S HV: Adjust nine checks for null pointers Thomas Huth
2017-01-20 18:24 ` [PATCH 06/11] KVM: PPC: Book3S HV: Use kcalloc() in kvmppc_alloc_host_rm_ops() SF Markus Elfring
2017-01-20 18:25 ` [PATCH 07/11] KVM: PPC: Book3S HV: Improve size determinations in five functions SF Markus Elfring
2017-01-20 18:26 ` [PATCH 08/11] KVM: PPC: Book3S: Use seq_puts() in xics_debug_show() SF Markus Elfring
2017-01-20 18:27 ` [PATCH 09/11] KVM: PPC: Book3S: Improve a size determination in two functions SF Markus Elfring
2017-01-21 6:24 ` kbuild test robot
2017-01-21 6:37 ` kbuild test robot
2017-01-20 18:28 ` [PATCH 10/11] KVM: PPC: e500: Use kcalloc() in e500_mmu_host_init() SF Markus Elfring
2017-01-20 18:29 ` [PATCH 11/11] KVM: PPC: Return directly after a failed copy_from_user() in two functions SF Markus Elfring
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=161c8660-d204-5190-9bda-c5a801abe0ab@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=agraf@suse.com \
--cc=benh@kernel.crashing.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.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;
as well as URLs for NNTP newsgroup(s).