arm64: KVM: Add braces to multi-line if statement in virtual PMU code
PATCH 1/1 arm64: KVM: Add braces to multi-line if statement in virtual PMU code
The kernel is written in C, not python, so we need braces around multi-line if statements. GCC 6 actually warns about this, thanks to the fantastic new "-Wmisleading-indentation" flag:
| virt/kvm/arm/pmu.c: In function ‘kvm_pmu_overflow_status’: | virt/kvm/arm/pmu.c:198:3: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation] | reg &= vcpu_sys_reg(vcpu, PMCNTENSET_EL0); | ^~~ | arch/arm64/kvm/../../../virt/kvm/arm/pmu.c:196:2: note: ...this ‘if’ clause, but it is not | if ((vcpu_sys_reg(vcpu, PMCR_EL0) & ARMV8_PMU_PMCR_E)) | ^~
As it turns out, this particular case is harmless (we just do some &= operations with 0), but worth fixing nonetheless.
--- virt/kvm/arm/pmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
virt/kvm/arm/pmu.c +2 -1
@@ -193,11 +193,12 @@ static u64 kvm_pmu_overflow_status(struct kvm_vcpu *vcpu) {u64 reg =0 ; -if ((vcpu_sys_reg (vcpu,PMCR_EL0 ) &ARMV8_PMU_PMCR_E )) +if ((vcpu_sys_reg (vcpu,PMCR_EL0 ) &ARMV8_PMU_PMCR_E )) { reg =vcpu_sys_reg (vcpu,PMOVSSET_EL0 ); reg &=vcpu_sys_reg (vcpu,PMCNTENSET_EL0 ); reg &=vcpu_sys_reg (vcpu,PMINTENSET_EL1 ); reg &=kvm_pmu_valid_counter_mask (vcpu); + }return reg; }
Signature · 6 lines
2.1.4 _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 3 lines · Will Deacon
The kernel is written in C, not python, so we need braces around multi-line if statements. GCC 6 actually warns about this, thanks to the fantastic new "-Wmisleading-indentation" flag:
We should rewrite the kernel in python!
Quoted 9 lines
| virt/kvm/arm/pmu.c: In function ‘kvm_pmu_overflow_status’: | virt/kvm/arm/pmu.c:198:3: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation] | reg &= vcpu_sys_reg(vcpu, PMCNTENSET_EL0); | ^~~ | arch/arm64/kvm/../../../virt/kvm/arm/pmu.c:196:2: note: ...this ‘if’ clause, but it is not | if ((vcpu_sys_reg(vcpu, PMCR_EL0) & ARMV8_PMU_PMCR_E)) | ^~
Quoted 4 lines
As it turns out, this particular case is harmless (we just do some &= operations with 0), but worth fixing nonetheless.
Signed-off-by Will Deacon <[email protected]>
Thanks for the patch.
-Christoffer
Quoted 25 lines
--- virt/kvm/arm/pmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)virt/kvm/arm/pmu.c +2
-1@@ -193,11 +193,12 @@ static u64 kvm_pmu_overflow_status(struct kvm_vcpu *vcpu) {u64 reg =0 ; -if ((vcpu_sys_reg (vcpu,PMCR_EL0 ) &ARMV8_PMU_PMCR_E )) +if ((vcpu_sys_reg (vcpu,PMCR_EL0 ) &ARMV8_PMU_PMCR_E )) { reg =vcpu_sys_reg (vcpu,PMOVSSET_EL0 ); reg &=vcpu_sys_reg (vcpu,PMCNTENSET_EL0 ); reg &=vcpu_sys_reg (vcpu,PMINTENSET_EL1 ); reg &=kvm_pmu_valid_counter_mask (vcpu); + }return reg; }Signature · 1 line
2.1.4
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 6 lines · Christoffer Dall
Quoted 3 lines · Will Deacon
The kernel is written in C, not python, so we need braces around multi-line if statements. GCC 6 actually warns about this, thanks to the fantastic new "-Wmisleading-indentation" flag:
We should rewrite the kernel in python!
Oh man, you made me look and I found this:
https://mail.python.org/pipermail/python-list/2004-October/283327.html
but, today's certainly the day for whacky suggestions.
Quoted 8 lines
Quoted 8 lines
| virt/kvm/arm/pmu.c: In function ‘kvm_pmu_overflow_status’: | virt/kvm/arm/pmu.c:198:3: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation] | reg &= vcpu_sys_reg(vcpu, PMCNTENSET_EL0); | ^~~ | arch/arm64/kvm/../../../virt/kvm/arm/pmu.c:196:2: note: ...this ‘if’ clause, but it is not | if ((vcpu_sys_reg(vcpu, PMCR_EL0) & ARMV8_PMU_PMCR_E)) | ^~
Quoted 6 lines
Quoted 4 lines
As it turns out, this particular case is harmless (we just do some &= operations with 0), but worth fixing nonetheless.
Signed-off-by Will Deacon <[email protected]>Thanks for the patch.
No problem. I timed it nicely with your pull request.
Will
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 11 lines · Will Deacon
Quoted 6 lines · Christoffer Dall
Quoted 3 lines · Will Deacon
The kernel is written in C, not python, so we need braces around multi-line if statements. GCC 6 actually warns about this, thanks to the fantastic new "-Wmisleading-indentation" flag:
We should rewrite the kernel in python!
Oh man, you made me look and I found this:
https://mail.python.org/pipermail/python-list/2004-October/283327.html
Haha, the reply saying "Great idea, go for it!" is hilarious.
Quoted 3 lines
but, today's certainly the day for whacky suggestions.
I wanted to have sent you and Catalin my Linux in EL2 patch set today, but it was still too messy and hacked up for that to be funny, unfortunately.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
| virt/kvm/arm/pmu.c: In function ‘kvm_pmu_overflow_status’: | virt/kvm/arm/pmu.c:198:3: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation] | reg &= vcpu_sys_reg(vcpu, PMCNTENSET_EL0); | ^~~ | arch/arm64/kvm/../../../virt/kvm/arm/pmu.c:196:2: note: ...this ‘if’ clause, but it is not | if ((vcpu_sys_reg(vcpu, PMCR_EL0) & ARMV8_PMU_PMCR_E)) | ^~
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
As it turns out, this particular case is harmless (we just do some &= operations with 0), but worth fixing nonetheless.
Signed-off-by Will Deacon <[email protected]>Thanks for the patch.
No problem. I timed it nicely with your pull request.
Yeah, I figure I will just add it to the next pull request, unless anyone objects to that.
-Christoffer
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Quoted 12 lines · Will Deacon
The kernel is written in C, not python, so we need braces around multi-line if statements. GCC 6 actually warns about this, thanks to the fantastic new "-Wmisleading-indentation" flag:
| virt/kvm/arm/pmu.c: In function ‘kvm_pmu_overflow_status’: | virt/kvm/arm/pmu.c:198:3: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation] | reg &= vcpu_sys_reg(vcpu, PMCNTENSET_EL0); | ^~~ | arch/arm64/kvm/../../../virt/kvm/arm/pmu.c:196:2: note: ...this ‘if’ clause, but it is not | if ((vcpu_sys_reg(vcpu, PMCR_EL0) & ARMV8_PMU_PMCR_E)) | ^~
Quoted 3 lines
As it turns out, this particular case is harmless (we just do some &= operations with 0), but worth fixing nonetheless.
Ah, thanks! I might be fooled at that moment. :)
Quoted 24 lines
Signed-off-by Will Deacon <[email protected]>--- virt/kvm/arm/pmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)virt/kvm/arm/pmu.c +2
-1@@ -193,11 +193,12 @@ static u64 kvm_pmu_overflow_status(struct kvm_vcpu *vcpu) {u64 reg =0 ; -if ((vcpu_sys_reg (vcpu,PMCR_EL0 ) &ARMV8_PMU_PMCR_E )) +if ((vcpu_sys_reg (vcpu,PMCR_EL0 ) &ARMV8_PMU_PMCR_E )) { reg =vcpu_sys_reg (vcpu,PMOVSSET_EL0 ); reg &=vcpu_sys_reg (vcpu,PMCNTENSET_EL0 ); reg &=vcpu_sys_reg (vcpu,PMINTENSET_EL1 ); reg &=kvm_pmu_valid_counter_mask (vcpu); + }return reg; }
Signature · 5 lines
Shannon _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm