Skip to contentSkip to conversation

KVM: arm64: Remove spurious semicolon in reg_to_encoding()

PATCH In review Marc Zyngier 2 participants 4 messages Dec 31, 2020 – Jan 5, 2021

Subsystems (2)
lore
Share & tools
lore

Marc Zyngier

author maintainer
#0 lore raw

PATCH 1/1 KVM: arm64: Remove spurious semicolon in reg_to_encoding()

Although not a problem right now, it flared up while working on some other aspects of the code-base. Remove the useless semicolon.

---
 arch/arm64/kvm/sys_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/sys_regs.c +1 -1
index d46e7f706cb0..42ccc27fb684 100644
@@ -923,7 +923,7 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
 
 #define reg_to_encoding(x)						\
 	sys_reg((u32)(x)->Op0, (u32)(x)->Op1,				\
-		(u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2);
+		(u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2)
 
 /* Silly macro to expand the DBG{BCR,BVR,WVR,WCR}n_EL1 registers in one go */
 #define DBG_BCR_BVR_WCR_WVR_EL1(n)					\
Signature · 6 lines
2.29.2

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Reviewed-by on v1 1/1
#1 lore raw

Hi Marc,

Quoted 14 lines · Marc Zyngier

Although not a problem right now, it flared up while working on some other aspects of the code-base. Remove the useless semicolon.

---
 arch/arm64/kvm/sys_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/sys_regs.c +0 -0
index d46e7f706cb0..42ccc27fb684 100644

arch/arm64/kvm/sys_regs.c static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, · line 926

Quoted 5 lines
arch/arm64/kvm/sys_regs.c +1 -1
@@ -923,7 +923,7 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
 
 #define reg_to_encoding(x)						\
 	sys_reg((u32)(x)->Op0, (u32)(x)->Op1,				\
-		(u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2);
+		(u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2)

Macro's shouldn't really end with a semicolon, otherwise code might break unexpectedly:

I skimmed over the code and the macro is used like a function. Do you think it's worth turning it into a function to gain type checking for the argument (which is expected to be sys_reg_desc) and for the return value?

Thanks,
Alex

arch/arm64/kvm/sys_regs.c static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, · line 929

Quoted 3 lines
arch/arm64/kvm/sys_regs.c +0 -0
 /* Silly macro to expand the DBG{BCR,BVR,WVR,WCR}n_EL1 registers in one go */
 #define DBG_BCR_BVR_WCR_WVR_EL1(n)					\

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

author maintainer
#2 lore raw
Quoted 27 lines · Alexandru Elisei

Hi Marc,

Quoted 14 lines · Marc Zyngier

Although not a problem right now, it flared up while working on some other aspects of the code-base. Remove the useless semicolon.

---
 arch/arm64/kvm/sys_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/sys_regs.c +0 -0
index d46e7f706cb0..42ccc27fb684 100644

arch/arm64/kvm/sys_regs.c static bool access_pmuserenr(struct kvm_vcpu · line 927

Quoted 6 lines
arch/arm64/kvm/sys_regs.c +1 -1
@@ -923,7 +923,7 @@ static bool access_pmuserenr(struct kvm_vcpu 
 *vcpu, struct sys_reg_params *p,
 
 #define reg_to_encoding(x)						\
 	sys_reg((u32)(x)->Op0, (u32)(x)->Op1,				\
-		(u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2);
+		(u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2)

Macro's shouldn't really end with a semicolon, otherwise code might break unexpectedly:

Quoted 6 lines

I skimmed over the code and the macro is used like a function. Do you think it's worth turning it into a function to gain type checking for the argument (which is
expected to be sys_reg_desc) and for the return value?

Not quite.

This macro takes indifferently a sys_reg_desc or a sys_reg_params, making it impossible to turn into a function. Is it disgusting and makes you want to pull your eyes out? Yes.

The whole params/desc duality dates back to the early 32bit code, and I blame Rusty Russell for it. Just saying... ;-)

That's one of things I always wanted to refactor...

Thanks,

        M.
Signature · 5 lines
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
#3 lore raw

Hi Marc,

Quoted 30 lines · Marc Zyngier
Quoted 29 lines · Alexandru Elisei

Hi Marc,

Quoted 14 lines · Marc Zyngier

Although not a problem right now, it flared up while working on some other aspects of the code-base. Remove the useless semicolon.

---
 arch/arm64/kvm/sys_regs.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/sys_regs.c +0 -0
index d46e7f706cb0..42ccc27fb684 100644

arch/arm64/kvm/sys_regs.c static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct · line 927

Quoted 6 lines
arch/arm64/kvm/sys_regs.c +1 -1
@@ -923,7 +923,7 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct
 sys_reg_params *p,
 
  #define reg_to_encoding(x)                        \
      sys_reg((u32)(x)->Op0, (u32)(x)->Op1,                \
-        (u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2);
+        (u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2)

Macro's shouldn't really end with a semicolon, otherwise code might break unexpectedly:

Quoted 8 lines
Quoted 4 lines

I skimmed over the code and the macro is used like a function. Do you think it's worth turning it into a function to gain type checking for the argument (which is
expected to be sys_reg_desc) and for the return value?

Not quite.

This macro takes indifferently a sys_reg_desc or a sys_reg_params,

Right, find_reg() calls reg_to_encoding() with a struct sys_reg_params argument, I missed that.

Found a few instances where sys_reg() calls can be replaced with reg_to_encoding(), will send a trivial patch for that.

Thanks,
Alex

Quoted 11 lines

making it impossible to turn into a function. Is it disgusting and makes you want to pull your eyes out? Yes.

The whole params/desc duality dates back to the early 32bit code, and I blame Rusty Russell for it. Just saying... ;-)

That's one of things I always wanted to refactor...

Thanks,

        M.

_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm