Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: Use ARRAY_SIZE macro instead of manual calculation.

Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Signed-off-by: Dor Laor <dor.laor@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>

authored by

Ahmed S. Darwish and committed by
Avi Kivity
9d8f549d de979caa

+7 -4
+2 -1
drivers/kvm/kvm_svm.h
··· 1 1 #ifndef __KVM_SVM_H 2 2 #define __KVM_SVM_H 3 3 4 + #include <linux/kernel.h> 4 5 #include <linux/types.h> 5 6 #include <linux/list.h> 6 7 #include <asm/msr.h> ··· 19 18 MSR_IA32_LASTBRANCHTOIP, MSR_IA32_LASTINTFROMIP,MSR_IA32_LASTINTTOIP,*/ 20 19 }; 21 20 22 - #define NR_HOST_SAVE_MSRS (sizeof(host_save_msrs) / sizeof(*host_save_msrs)) 21 + #define NR_HOST_SAVE_MSRS ARRAY_SIZE(host_save_msrs) 23 22 #define NUM_DB_REGS 4 24 23 25 24 struct vcpu_svm {
+3 -2
drivers/kvm/svm.c
··· 15 15 */ 16 16 17 17 #include <linux/module.h> 18 + #include <linux/kernel.h> 18 19 #include <linux/vmalloc.h> 19 20 #include <linux/highmem.h> 20 21 #include <linux/profile.h> ··· 76 75 77 76 static u32 msrpm_ranges[] = {0, 0xc0000000, 0xc0010000}; 78 77 79 - #define NUM_MSR_MAPS (sizeof(msrpm_ranges) / sizeof(*msrpm_ranges)) 78 + #define NUM_MSR_MAPS ARRAY_SIZE(msrpm_ranges) 80 79 #define MSRS_RANGE_SIZE 2048 81 80 #define MSRS_IN_RANGE (MSRS_RANGE_SIZE * 8 / 2) 82 81 ··· 1298 1297 __FUNCTION__, vcpu->svm->vmcb->control.exit_int_info, 1299 1298 exit_code); 1300 1299 1301 - if (exit_code >= sizeof(svm_exit_handlers) / sizeof(*svm_exit_handlers) 1300 + if (exit_code >= ARRAY_SIZE(svm_exit_handlers) 1302 1301 || svm_exit_handlers[exit_code] == 0) { 1303 1302 kvm_run->exit_reason = KVM_EXIT_UNKNOWN; 1304 1303 printk(KERN_ERR "%s: 0x%x @ 0x%llx cr0 0x%lx rflags 0x%llx\n",
+2 -1
drivers/kvm/vmx.c
··· 19 19 #include "vmx.h" 20 20 #include "kvm_vmx.h" 21 21 #include <linux/module.h> 22 + #include <linux/kernel.h> 22 23 #include <linux/mm.h> 23 24 #include <linux/highmem.h> 24 25 #include <linux/profile.h> ··· 76 75 #endif 77 76 MSR_EFER, MSR_K6_STAR, 78 77 }; 79 - #define NR_VMX_MSR (sizeof(vmx_msr_index) / sizeof(*vmx_msr_index)) 78 + #define NR_VMX_MSR ARRAY_SIZE(vmx_msr_index) 80 79 81 80 static inline int is_page_fault(u32 intr_info) 82 81 {