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@xxxxxxxxxx> --- 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