Commit 5d9cd8b5 authored by Guo Zhengkui's avatar Guo Zhengkui Committed by Paolo Bonzini

selftests: kvm: replace ternary operator with min()

Fix the following coccicheck warnings:

tools/testing/selftests/kvm/lib/s390x/ucall.c:25:15-17: WARNING
opportunity for min()
tools/testing/selftests/kvm/lib/x86_64/ucall.c:27:15-17: WARNING
opportunity for min()
tools/testing/selftests/kvm/lib/riscv/ucall.c:56:15-17: WARNING
opportunity for min()
tools/testing/selftests/kvm/lib/aarch64/ucall.c:82:15-17: WARNING
opportunity for min()
tools/testing/selftests/kvm/lib/aarch64/ucall.c:55:20-21: WARNING
opportunity for min()

min() is defined in tools/include/linux/kernel.h.
Signed-off-by: default avatarGuo Zhengkui <guozhengkui@vivo.com>
Acked-by: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
Acked-by: default avatarAnup Patel <anup@brainfault.org>
Message-Id: <20220511120621.36956-1-guozhengkui@vivo.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent cf8e55fe
...@@ -52,7 +52,7 @@ void ucall_init(struct kvm_vm *vm, void *arg) ...@@ -52,7 +52,7 @@ void ucall_init(struct kvm_vm *vm, void *arg)
* lower and won't match physical addresses. * lower and won't match physical addresses.
*/ */
bits = vm->va_bits - 1; bits = vm->va_bits - 1;
bits = vm->pa_bits < bits ? vm->pa_bits : bits; bits = min(vm->pa_bits, bits);
end = 1ul << bits; end = 1ul << bits;
start = end * 5 / 8; start = end * 5 / 8;
step = end / 16; step = end / 16;
...@@ -79,7 +79,7 @@ void ucall(uint64_t cmd, int nargs, ...) ...@@ -79,7 +79,7 @@ void ucall(uint64_t cmd, int nargs, ...)
va_list va; va_list va;
int i; int i;
nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS; nargs = min(nargs, UCALL_MAX_ARGS);
va_start(va, nargs); va_start(va, nargs);
for (i = 0; i < nargs; ++i) for (i = 0; i < nargs; ++i)
......
...@@ -53,7 +53,7 @@ void ucall(uint64_t cmd, int nargs, ...) ...@@ -53,7 +53,7 @@ void ucall(uint64_t cmd, int nargs, ...)
va_list va; va_list va;
int i; int i;
nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS; nargs = min(nargs, UCALL_MAX_ARGS);
va_start(va, nargs); va_start(va, nargs);
for (i = 0; i < nargs; ++i) for (i = 0; i < nargs; ++i)
......
...@@ -22,7 +22,7 @@ void ucall(uint64_t cmd, int nargs, ...) ...@@ -22,7 +22,7 @@ void ucall(uint64_t cmd, int nargs, ...)
va_list va; va_list va;
int i; int i;
nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS; nargs = min(nargs, UCALL_MAX_ARGS);
va_start(va, nargs); va_start(va, nargs);
for (i = 0; i < nargs; ++i) for (i = 0; i < nargs; ++i)
......
...@@ -24,7 +24,7 @@ void ucall(uint64_t cmd, int nargs, ...) ...@@ -24,7 +24,7 @@ void ucall(uint64_t cmd, int nargs, ...)
va_list va; va_list va;
int i; int i;
nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS; nargs = min(nargs, UCALL_MAX_ARGS);
va_start(va, nargs); va_start(va, nargs);
for (i = 0; i < nargs; ++i) for (i = 0; i < nargs; ++i)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment