[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] target/i386/kvm: Replace KVM_MSR_FILTER_MAX_RANGES with ARRAY_SI
From: |
Zhao Liu |
Subject: |
[PATCH] target/i386/kvm: Replace KVM_MSR_FILTER_MAX_RANGES with ARRAY_SIZE(msr_handlers) |
Date: |
Wed, 8 Jan 2025 23:19:46 +0800 |
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 <zide.chen@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
Changelog:
* Addressed Paolo's comment [1] to choose ARRAY_SIZE(msr_handlers).
[1]:
https://lore.kernel.org/qemu-devel/5463356b-827f-4c9f-a76e-02cd580fe885@redhat.com/
---
target/i386/kvm/kvm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index 2f66e63b880a..7424a3f5cf48 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -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++];
--
2.34.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] target/i386/kvm: Replace KVM_MSR_FILTER_MAX_RANGES with ARRAY_SIZE(msr_handlers),
Zhao Liu <=