Skip to contentSkip to conversation

KVM: x86: Fix errors in vmcs12.c

PATCH In review [email protected] 2 participants 2 messages Jul 12, 2023 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 KVM: x86: Fix errors in vmcs12.c

The following checkpatch errors are removed:
ERROR: space prohibited before open square bracket '['
ERROR: Macros with complex values should be enclosed in parentheses

---
 arch/x86/kvm/vmx/vmcs12.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/vmcs12.c +2 -2
index 106a72c923ca..da239ca58f90 100644
@@ -4,10 +4,10 @@
 #include "vmcs12.h"
 
 #define VMCS12_OFFSET(x) offsetof(struct vmcs12, x)
-#define FIELD(number, name)    [ROL16(number, 6)] = VMCS12_OFFSET(name)
+#define FIELD(number, name)[ROL16(number, 6)] = VMCS12_OFFSET(name)
 #define FIELD64(number, name)                        \
     FIELD(number, name),                        \
-    [ROL16(number##_HIGH, 6)] = VMCS12_OFFSET(name) + sizeof(u32)
+    [ROL16(number##_HIGH, 6)] = (VMCS12_OFFSET(name) + sizeof(u32))
 
 const unsigned short vmcs12_field_offsets[] = {
     FIELD(VIRTUAL_PROCESSOR_ID, virtual_processor_id),
#2 lore raw

Le 12/07/2023 à 10:40, [email protected] a écrit :

Quoted 14 lines

The following checkpatch errors are removed:
ERROR: space prohibited before open square bracket '['
ERROR: Macros with complex values should be enclosed in parentheses

---
  arch/x86/kvm/vmx/vmcs12.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/vmcs12.c +0 -0
index 106a72c923ca..da239ca58f90 100644

arch/x86/kvm/vmx/vmcs12.c line 7

Quoted 5 lines
arch/x86/kvm/vmx/vmcs12.c +1 -1
@@ -4,10 +4,10 @@
  #include "vmcs12.h"
 
  #define VMCS12_OFFSET(x) offsetof(struct vmcs12, x)
-#define FIELD(number, name)    [ROL16(number, 6)] = VMCS12_OFFSET(name)
+#define FIELD(number, name)[ROL16(number, 6)] = VMCS12_OFFSET(name)

Hi,

Written this way, this is really counter-intuitive.
I think that the checkpatch warning should be ignored in this case.

arch/x86/kvm/vmx/vmcs12.c line 10

Quoted 4 lines
arch/x86/kvm/vmx/vmcs12.c +1 -1
  #define FIELD64(number, name)                        \
      FIELD(number, name),                        \
-    [ROL16(number##_HIGH, 6)] = VMCS12_OFFSET(name) + sizeof(u32)
+    [ROL16(number##_HIGH, 6)] = (VMCS12_OFFSET(name) + sizeof(u32))

This does not silence the checkpatch warning.
I think that the checkpatch warning should also be ignored in this case.

arch/x86/kvm/vmx/vmcs12.c

Quoted 4 lines
arch/x86/kvm/vmx/vmcs12.c +0 -0
  const unsigned short vmcs12_field_offsets[] = {
      FIELD(VIRTUAL_PROCESSOR_ID, virtual_processor_id),
 

checkpatch output should always be taken with a grain of salt.
It just runs some heuristics on what looks improvable, but it is not THE law.

It is just a tool that can help in many cases, but not all.

Here, I think that the code is better as-is.

CJ