aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sysemu/kvm.h14
1 files changed, 4 insertions, 10 deletions
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 91fc07ee9a..3a458f50e9 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -428,11 +428,8 @@ int kvm_vm_check_extension(KVMState *s, unsigned int extension);
.flags = cap_flags, \
}; \
uint64_t args_tmp[] = { __VA_ARGS__ }; \
- int i; \
- for (i = 0; i < (int)ARRAY_SIZE(args_tmp) && \
- i < ARRAY_SIZE(cap.args); i++) { \
- cap.args[i] = args_tmp[i]; \
- } \
+ size_t n = MIN(ARRAY_SIZE(args_tmp), ARRAY_SIZE(cap.args)); \
+ memcpy(cap.args, args_tmp, n * sizeof(cap.args[0])); \
kvm_vm_ioctl(s, KVM_ENABLE_CAP, &cap); \
})
@@ -443,11 +440,8 @@ int kvm_vm_check_extension(KVMState *s, unsigned int extension);
.flags = cap_flags, \
}; \
uint64_t args_tmp[] = { __VA_ARGS__ }; \
- int i; \
- for (i = 0; i < (int)ARRAY_SIZE(args_tmp) && \
- i < ARRAY_SIZE(cap.args); i++) { \
- cap.args[i] = args_tmp[i]; \
- } \
+ size_t n = MIN(ARRAY_SIZE(args_tmp), ARRAY_SIZE(cap.args)); \
+ memcpy(cap.args, args_tmp, n * sizeof(cap.args[0])); \
kvm_vcpu_ioctl(cpu, KVM_ENABLE_CAP, &cap); \
})