[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221101072513.7364-1-liubo03@inspur.com>
Date: Tue, 1 Nov 2022 03:25:13 -0400
From: Bo Liu <liubo03@...pur.com>
To: <pbonzini@...hat.com>
CC: <kvm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
Bo Liu <liubo03@...pur.com>
Subject: [PATCH] KVM: replace ternary operator with min()
Fix the following coccicheck warning:
virt/kvm/kvm_main.c:5289:10-11: WARNING opportunity for min()
virt/kvm/kvm_main.c:5218:10-11: WARNING opportunity for min()
min() macro is defined in include/linux/minmax.h. It avoids
multiple evaluations of the arguments when non-constant and
performs strict type-checking.
Signed-off-by: Bo Liu <liubo03@...pur.com>
---
virt/kvm/kvm_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 3f383f27d3d7..45a56a9600e1 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -5215,7 +5215,7 @@ int kvm_io_bus_write(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx, gpa_t addr,
if (!bus)
return -ENOMEM;
r = __kvm_io_bus_write(vcpu, bus, &range, val);
- return r < 0 ? r : 0;
+ return min(r, 0);
}
EXPORT_SYMBOL_GPL(kvm_io_bus_write);
@@ -5286,7 +5286,7 @@ int kvm_io_bus_read(struct kvm_vcpu *vcpu, enum kvm_bus bus_idx, gpa_t addr,
if (!bus)
return -ENOMEM;
r = __kvm_io_bus_read(vcpu, bus, &range, val);
- return r < 0 ? r : 0;
+ return min(r, 0);
}
/* Caller must hold slots_lock. */
--
2.27.0
Powered by blists - more mailing lists