Compile error with CONFIG_KVM_INTEL=y and W=1: CC arch/x86/kvm/vmx/vmx.o arch/x86/kvm/vmx/vmx.c:68:32: error: 'vmx_cpu_id' defined but not used [-Werror=unused-const-variable=] 68 | static const struct x86_cpu_id vmx_cpu_id[] = { | ^~~~~~~~~~ cc1: all warnings being treated as errors When building with =y, the MODULE_DEVICE_TABLE macro doesn't generate a reference to the structure (or any code at all). This makes W=1 compiles unhappy. Wrap both in a #ifdef to avoid the issue.
Unified · Split
| @@ -57,11 +57,13 @@ · 56 unmodified lines | ||
| 57 | 57 | MODULE_AUTHOR("Qumranet"); |
| 58 | 58 | MODULE_LICENSE("GPL"); |
| 59 | 59 | |
| 60 | +#ifdef MODULE | |
| 60 | 61 | static const struct x86_cpu_id svm_cpu_id[] = { |
| 61 | 62 | X86_FEATURE_MATCH(X86_FEATURE_SVM), |
| 62 | 63 | {} |
| 63 | 64 | }; |
| 64 | 65 | MODULE_DEVICE_TABLE(x86cpu, svm_cpu_id); |
| 66 | +#endif | |
| 65 | 67 | |
| 66 | 68 | #define IOPM_ALLOC_ORDER 2 |
| 67 | 69 | #define MSRPM_ALLOC_ORDER 1 |
| @@ -64,11 +64,13 @@ · 63 unmodified lines | ||
| 64 | 64 | MODULE_AUTHOR("Qumranet"); |
| 65 | 65 | MODULE_LICENSE("GPL"); |
| 66 | 66 | |
| 67 | +#ifdef MODULE | |
| 67 | 68 | static const struct x86_cpu_id vmx_cpu_id[] = { |
| 68 | 69 | X86_FEATURE_MATCH(X86_FEATURE_VMX), |
| 69 | 70 | {} |
| 70 | 71 | }; |
| 71 | 72 | MODULE_DEVICE_TABLE(x86cpu, vmx_cpu_id); |
| 73 | +#endif | |
| 72 | 74 | |
| 73 | 75 | bool __read_mostly enable_vpid = 1; |
| 74 | 76 | module_param_named(vpid, enable_vpid, bool, 0444); |