target/i386/kvm: Replace KVM_MSR_FILTER_MAX_RANGES with ARRAY_SIZE(msr_handlers)
PATCH 1/1 target/i386/kvm: Replace KVM_MSR_FILTER_MAX_RANGES with ARRAY_SIZE(msr_handlers)
kvm_install_msr_filters() uses KVM_MSR_FILTER_MAX_RANGES as the bound when traversing msr_handlers[], while other places compute the size by ARRAY_SIZE(msr_handlers).
In fact, msr_handlers[] is an array with the fixed size KVM_MSR_FILTER_MAX_RANGES, so there is no difference between the two ways.
For the code consistency, use ARRAY_SIZE(msr_handlers) uniformly instead of KVM_MSR_FILTER_MAX_RANGES.
Suggested-by Zide Chen <[email protected]>
Signed-off-by Zhao Liu <[email protected]>
---
Changelog:
* Addressed Paolo's comment [1] to choose ARRAY_SIZE(msr_handlers).
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
--- target/i386/kvm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/kvm/kvm.c +1 -1
@@ -5851,7 +5851,7 @@ static bool kvm_install_msr_filters(KVMState *s) };int r, i, j =0 ; -for (i =0 ; i <KVM_MSR_FILTER_MAX_RANGES ; i++) { +for (i =0 ; i <ARRAY_SIZE (msr_handlers); i++) {KVMMSRHandlers *handler = &msr_handlers[i];if (handler->msr) {struct kvm_msr_filter_range *range = &filter.ranges[j++];
Signature · 1 line
2.34.1