linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: KVM: Add braces to multi-line if statement in virtual PMU code
@ 2016-04-01 11:12 Will Deacon
  2016-04-01 11:30 ` Christoffer Dall
  2016-04-01 14:23 ` Shannon Zhao
  0 siblings, 2 replies; 5+ messages in thread
From: Will Deacon @ 2016-04-01 11:12 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 virt/kvm/arm/pmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c
index b5754c6c5508..575c7aa30d7e 100644
--- a/virt/kvm/arm/pmu.c
+++ b/virt/kvm/arm/pmu.c
@@ -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;
 }
-- 
2.1.4

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

* [PATCH] arm64: KVM: Add braces to multi-line if statement in virtual PMU code
  2016-04-01 11:12 [PATCH] arm64: KVM: Add braces to multi-line if statement in virtual PMU code Will Deacon
@ 2016-04-01 11:30 ` Christoffer Dall
  2016-04-01 11:36   ` Will Deacon
  2016-04-01 14:23 ` Shannon Zhao
  1 sibling, 1 reply; 5+ messages in thread
From: Christoffer Dall @ 2016-04-01 11:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 01, 2016 at 12:12:22PM +0100, Will Deacon wrote:
> 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!

> 
>  | 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.
> 
> Signed-off-by: Will Deacon <will.deacon@arm.com>

Thanks for the patch.

-Christoffer

> ---
>  virt/kvm/arm/pmu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c
> index b5754c6c5508..575c7aa30d7e 100644
> --- a/virt/kvm/arm/pmu.c
> +++ b/virt/kvm/arm/pmu.c
> @@ -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;
>  }
> -- 
> 2.1.4
> 

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

* [PATCH] arm64: KVM: Add braces to multi-line if statement in virtual PMU code
  2016-04-01 11:30 ` Christoffer Dall
@ 2016-04-01 11:36   ` Will Deacon
  2016-04-01 12:10     ` Christoffer Dall
  0 siblings, 1 reply; 5+ messages in thread
From: Will Deacon @ 2016-04-01 11:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 01, 2016 at 01:30:40PM +0200, Christoffer Dall wrote:
> On Fri, Apr 01, 2016 at 12:12:22PM +0100, Will Deacon wrote:
> > 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.

> >  | 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.
> > 
> > Signed-off-by: Will Deacon <will.deacon@arm.com>
> 
> Thanks for the patch.

No problem. I timed it nicely with your pull request.

Will

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

* [PATCH] arm64: KVM: Add braces to multi-line if statement in virtual PMU code
  2016-04-01 11:36   ` Will Deacon
@ 2016-04-01 12:10     ` Christoffer Dall
  0 siblings, 0 replies; 5+ messages in thread
From: Christoffer Dall @ 2016-04-01 12:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 01, 2016 at 12:36:25PM +0100, Will Deacon wrote:
> On Fri, Apr 01, 2016 at 01:30:40PM +0200, Christoffer Dall wrote:
> > On Fri, Apr 01, 2016 at 12:12:22PM +0100, Will Deacon wrote:
> > > 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.

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

> > >  | 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.
> > > 
> > > Signed-off-by: Will Deacon <will.deacon@arm.com>
> > 
> > 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

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

* [PATCH] arm64: KVM: Add braces to multi-line if statement in virtual PMU code
  2016-04-01 11:12 [PATCH] arm64: KVM: Add braces to multi-line if statement in virtual PMU code Will Deacon
  2016-04-01 11:30 ` Christoffer Dall
@ 2016-04-01 14:23 ` Shannon Zhao
  1 sibling, 0 replies; 5+ messages in thread
From: Shannon Zhao @ 2016-04-01 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 2016?04?01? 19:12, Will Deacon wrote:
> 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.
> 
Ah, thanks! I might be fooled at that moment. :)

Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>

> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>  virt/kvm/arm/pmu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c
> index b5754c6c5508..575c7aa30d7e 100644
> --- a/virt/kvm/arm/pmu.c
> +++ b/virt/kvm/arm/pmu.c
> @@ -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;
>  }
> 


-- 
Shannon

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

end of thread, other threads:[~2016-04-01 14:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-01 11:12 [PATCH] arm64: KVM: Add braces to multi-line if statement in virtual PMU code Will Deacon
2016-04-01 11:30 ` Christoffer Dall
2016-04-01 11:36   ` Will Deacon
2016-04-01 12:10     ` Christoffer Dall
2016-04-01 14:23 ` Shannon Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).