* [PATCH] arm_pmu: fix compiler warning in arm_pmu_device_probe
@ 2018-08-01 21:45 Chris Packham
2018-08-02 10:55 ` Robin Murphy
2018-08-02 10:57 ` Will Deacon
0 siblings, 2 replies; 4+ messages in thread
From: Chris Packham @ 2018-08-01 21:45 UTC (permalink / raw)
To: mark.rutland, will.deacon; +Cc: linux-arm-kernel, linux-kernel, Chris Packham
GCC warns
arm_pmu_platform.c:234:5: error: 'err' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This is because we rely on the for_each_cpu loop in armpmu_request_irqs
to initialise err. The warning is a little bogus because we know if
there were 0 CPUs this code would not be running.
Initialise err to 0 to avoid the warning.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
This has been reported before in https://lkml.org/lkml/2018/3/5/508 I'm not
sure if it was dismmissed as "meh, gcc is wrong" or if it was just wainting for
someone with some round tuits.
drivers/perf/arm_pmu_platform.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platform.c
index 971ff336494a..96075cecb0ae 100644
--- a/drivers/perf/arm_pmu_platform.c
+++ b/drivers/perf/arm_pmu_platform.c
@@ -160,7 +160,7 @@ static int pmu_parse_irqs(struct arm_pmu *pmu)
static int armpmu_request_irqs(struct arm_pmu *armpmu)
{
struct pmu_hw_events __percpu *hw_events = armpmu->hw_events;
- int cpu, err;
+ int cpu, err = 0;
for_each_cpu(cpu, &armpmu->supported_cpus) {
int irq = per_cpu(hw_events->irq, cpu);
--
2.18.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arm_pmu: fix compiler warning in arm_pmu_device_probe
2018-08-01 21:45 [PATCH] arm_pmu: fix compiler warning in arm_pmu_device_probe Chris Packham
@ 2018-08-02 10:55 ` Robin Murphy
2018-08-02 10:57 ` Will Deacon
1 sibling, 0 replies; 4+ messages in thread
From: Robin Murphy @ 2018-08-02 10:55 UTC (permalink / raw)
To: Chris Packham, mark.rutland, will.deacon; +Cc: linux-kernel, linux-arm-kernel
Hi Chris,
On 01/08/18 22:45, Chris Packham wrote:
> GCC warns
>
> arm_pmu_platform.c:234:5: error: 'err' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> This is because we rely on the for_each_cpu loop in armpmu_request_irqs
> to initialise err. The warning is a little bogus because we know if
> there were 0 CPUs this code would not be running.
>
> Initialise err to 0 to avoid the warning.
Maybe initialising to something like -EINVAL would be more appropriate,
just in case we did ever manage to get here with armpmu->supported_cpus
unset?
Robin.
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> This has been reported before in https://lkml.org/lkml/2018/3/5/508 I'm not
> sure if it was dismmissed as "meh, gcc is wrong" or if it was just wainting for
> someone with some round tuits.
>
>
> drivers/perf/arm_pmu_platform.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/perf/arm_pmu_platform.c b/drivers/perf/arm_pmu_platform.c
> index 971ff336494a..96075cecb0ae 100644
> --- a/drivers/perf/arm_pmu_platform.c
> +++ b/drivers/perf/arm_pmu_platform.c
> @@ -160,7 +160,7 @@ static int pmu_parse_irqs(struct arm_pmu *pmu)
> static int armpmu_request_irqs(struct arm_pmu *armpmu)
> {
> struct pmu_hw_events __percpu *hw_events = armpmu->hw_events;
> - int cpu, err;
> + int cpu, err = 0;
>
> for_each_cpu(cpu, &armpmu->supported_cpus) {
> int irq = per_cpu(hw_events->irq, cpu);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm_pmu: fix compiler warning in arm_pmu_device_probe
2018-08-01 21:45 [PATCH] arm_pmu: fix compiler warning in arm_pmu_device_probe Chris Packham
2018-08-02 10:55 ` Robin Murphy
@ 2018-08-02 10:57 ` Will Deacon
2018-08-02 21:21 ` Chris Packham
1 sibling, 1 reply; 4+ messages in thread
From: Will Deacon @ 2018-08-02 10:57 UTC (permalink / raw)
To: Chris Packham; +Cc: mark.rutland, linux-arm-kernel, linux-kernel
On Thu, Aug 02, 2018 at 09:45:26AM +1200, Chris Packham wrote:
> GCC warns
>
> arm_pmu_platform.c:234:5: error: 'err' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> This is because we rely on the for_each_cpu loop in armpmu_request_irqs
> to initialise err. The warning is a little bogus because we know if
> there were 0 CPUs this code would not be running.
>
> Initialise err to 0 to avoid the warning.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> This has been reported before in https://lkml.org/lkml/2018/3/5/508 I'm not
> sure if it was dismmissed as "meh, gcc is wrong" or if it was just wainting for
> someone with some round tuits.
Which version of GCC are you using? I don't see this warning locally.
Will
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arm_pmu: fix compiler warning in arm_pmu_device_probe
2018-08-02 10:57 ` Will Deacon
@ 2018-08-02 21:21 ` Chris Packham
0 siblings, 0 replies; 4+ messages in thread
From: Chris Packham @ 2018-08-02 21:21 UTC (permalink / raw)
To: Will Deacon; +Cc: mark.rutland, linux-arm-kernel, linux-kernel
On 02/08/18 23:05, Will Deacon wrote:
> On Thu, Aug 02, 2018 at 09:45:26AM +1200, Chris Packham wrote:
>> GCC warns
>>
>> arm_pmu_platform.c:234:5: error: 'err' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>
>> This is because we rely on the for_each_cpu loop in armpmu_request_irqs
>> to initialise err. The warning is a little bogus because we know if
>> there were 0 CPUs this code would not be running.
>>
>> Initialise err to 0 to avoid the warning.
>>
>> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
>> ---
>> This has been reported before in https://lkml.org/lkml/2018/3/5/508 I'm not
>> sure if it was dismmissed as "meh, gcc is wrong" or if it was just wainting for
>> someone with some round tuits.
>
> Which version of GCC are you using? I don't see this warning locally.
>
My local cross-compiler is
$ arm-softfloat-linux-gnueabi-gcc --version
arm-softfloat-linux-gnueabi-gcc (crosstool-NG crosstool-ng-1.22.0) 4.9.3
Old-ish but as far as I was aware still supported for building the kernel.
I've just tried 7.3.0 and 8.1.0 neither of which complain.
A quick look at the report linked to above seems they probably were
using 4.6.3 and it still appears in current build reports
http://kisskb.ellerman.id.au/kisskb/buildresult/13455291/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-08-02 21:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-01 21:45 [PATCH] arm_pmu: fix compiler warning in arm_pmu_device_probe Chris Packham
2018-08-02 10:55 ` Robin Murphy
2018-08-02 10:57 ` Will Deacon
2018-08-02 21:21 ` Chris Packham
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).