All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhaoxiao <zhaoxiao@uniontech.com>
To: kvm@vger.kernel.org
Cc: zhaoxiao <zhaoxiao@uniontech.com>
Subject: [PATCH] KVM: Fix the warning by the min()
Date: Wed, 17 Nov 2021 08:55:45 +0800	[thread overview]
Message-ID: <20211117005545.26214-1-zhaoxiao@uniontech.com> (raw)

Fix following coccicheck warning:
virt/kvm/kvm_main.c:4995:10-11: WARNING opportunity for min()
virt/kvm/kvm_main.c:4924:10-11: WARNING opportunity for min()

Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
---
 virt/kvm/kvm_main.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index d31724500501..bd646c64722d 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -4910,7 +4910,6 @@ int kvm_io_bus_write(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx, gpa_t addr,
 {
 	struct kvm_io_bus *bus;
 	struct kvm_io_range range;
-	int r;
 
 	range = (struct kvm_io_range) {
 		.addr = addr,
@@ -4920,8 +4919,8 @@ int kvm_io_bus_write(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx, gpa_t addr,
 	bus = srcu_dereference(vcpu->kvm->buses[bus_idx], &vcpu->kvm->srcu);
 	if (!bus)
 		return -ENOMEM;
-	r = __kvm_io_bus_write(vcpu, bus, &range, val);
-	return r < 0 ? r : 0;
+
+	return min(__kvm_io_bus_write(vcpu, bus, &range, val), 0);
 }
 EXPORT_SYMBOL_GPL(kvm_io_bus_write);
 
@@ -4981,7 +4980,6 @@ int kvm_io_bus_read(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx, gpa_t addr,
 {
 	struct kvm_io_bus *bus;
 	struct kvm_io_range range;
-	int r;
 
 	range = (struct kvm_io_range) {
 		.addr = addr,
@@ -4991,8 +4989,8 @@ int kvm_io_bus_read(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx, gpa_t addr,
 	bus = srcu_dereference(vcpu->kvm->buses[bus_idx], &vcpu->kvm->srcu);
 	if (!bus)
 		return -ENOMEM;
-	r = __kvm_io_bus_read(vcpu, bus, &range, val);
-	return r < 0 ? r : 0;
+
+	return min(__kvm_io_bus_read(vcpu, bus, &range, val), 0);
 }
 
 /* Caller must hold slots_lock. */
-- 
2.20.1




             reply	other threads:[~2021-11-17  0:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17  0:55 zhaoxiao [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-11-16 12:10 [PATCH] KVM: Fix the warning by the min() zhaoxiao
2021-11-16 15:56 ` Paolo Bonzini
2021-11-17 22:19   ` Sean Christopherson

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=20211117005545.26214-1-zhaoxiao@uniontech.com \
    --to=zhaoxiao@uniontech.com \
    --cc=kvm@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.