mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Fix errors in vmcs12.c
       [not found] <tencent_833CA5C82FF883DD2261815EDE19C9858D0A@qq.com>
@ 2023-07-12  8:40 ` shijie001
  2023-07-12 17:32   ` Christophe JAILLET
  0 siblings, 1 reply; 2+ messages in thread
From: shijie001 @ 2023-07-12  8:40 UTC (permalink / raw)
  To: tglx, mingo, mingo, mingo, mingo; +Cc: Hpa, Kvm, Linux Kernel

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

Signed-off-by: Jie Shi <shijie001@208suo.com>
---
  arch/x86/kvm/vmx/vmcs12.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx/vmcs12.c b/arch/x86/kvm/vmx/vmcs12.c
index 106a72c923ca..da239ca58f90 100644
--- a/arch/x86/kvm/vmx/vmcs12.c
+++ b/arch/x86/kvm/vmx/vmcs12.c
@@ -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),

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: x86: Fix errors in vmcs12.c
  2023-07-12  8:40 ` [PATCH] KVM: x86: Fix errors in vmcs12.c shijie001
@ 2023-07-12 17:32   ` Christophe JAILLET
  0 siblings, 0 replies; 2+ messages in thread
From: Christophe JAILLET @ 2023-07-12 17:32 UTC (permalink / raw)
  To: shijie001, tglx, mingo; +Cc: Hpa, Kvm, Linux Kernel

Le 12/07/2023 à 10:40, shijie001@208suo.com a écrit :
> The following checkpatch errors are removed:
> ERROR: space prohibited before open square bracket '['
> ERROR: Macros with complex values should be enclosed in parentheses
> 
> Signed-off-by: Jie Shi <shijie001@208suo.com>
> ---
>   arch/x86/kvm/vmx/vmcs12.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx/vmcs12.c b/arch/x86/kvm/vmx/vmcs12.c
> index 106a72c923ca..da239ca58f90 100644
> --- a/arch/x86/kvm/vmx/vmcs12.c
> +++ b/arch/x86/kvm/vmx/vmcs12.c
> @@ -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.

>   #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.

> 
>   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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-12 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <tencent_833CA5C82FF883DD2261815EDE19C9858D0A@qq.com>
2023-07-12  8:40 ` [PATCH] KVM: x86: Fix errors in vmcs12.c shijie001
2023-07-12 17:32   ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®