* [PATCH] vexpress/spc: fix a build warning on array bounds
@ 2014-07-16 11:21 Alex Shi
2014-07-16 11:28 ` Sudeep Holla
0 siblings, 1 reply; 5+ messages in thread
From: Alex Shi @ 2014-07-16 11:21 UTC (permalink / raw)
To: linux
Cc: pawel.moll, nico, sudeep.karkadanagesha, viresh.kumar,
rafael.j.wysocki, linux-kernel, mark.brown, tixy
With ARCH_VEXPRESS_SPC option, kernel build has the following
warning:
arch/arm/mach-vexpress/spc.c: In function ‘ve_spc_clk_init’:
arch/arm/mach-vexpress/spc.c:431:38: warning: array subscript is below array bounds [-Warray-bounds]
struct ve_spc_opp *opps = info->opps[cluster];
^
since 'cluster' maybe '-1' in UP system. This patch does a active
checking to fix this issue.
Signed-off-by: Alex Shi <alex.shi@linaro.org>
---
arch/arm/mach-vexpress/spc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
index c26ef5b..4833544 100644
--- a/arch/arm/mach-vexpress/spc.c
+++ b/arch/arm/mach-vexpress/spc.c
@@ -426,9 +426,15 @@ static int ve_spc_populate_opps(uint32_t cluster)
static int ve_init_opp_table(struct device *cpu_dev)
{
- int cluster = topology_physical_package_id(cpu_dev->id);
- int idx, ret = 0, max_opp = info->num_opps[cluster];
- struct ve_spc_opp *opps = info->opps[cluster];
+ int cluster;
+ int idx, ret = 0, max_opp;
+ struct ve_spc_opp *opps;
+
+ cluster = topology_physical_package_id(cpu_dev->id);
+ cluster = cluster < 0 ? 0 : cluster;
+
+ max_opp = info->num_opps[cluster];
+ opps = info->opps[cluster];
for (idx = 0; idx < max_opp; idx++, opps++) {
ret = dev_pm_opp_add(cpu_dev, opps->freq * 1000, opps->u_volt);
@@ -537,6 +543,8 @@ static struct clk *ve_spc_clk_register(struct device *cpu_dev)
spc->hw.init = &init;
spc->cluster = topology_physical_package_id(cpu_dev->id);
+ spc->cluster = spc->cluster < 0 ? 0 : spc->cluster;
+
init.name = dev_name(cpu_dev);
init.ops = &clk_spc_ops;
init.flags = CLK_IS_ROOT | CLK_GET_RATE_NOCACHE;
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] vexpress/spc: fix a build warning on array bounds
2014-07-16 11:21 [PATCH] vexpress/spc: fix a build warning on array bounds Alex Shi
@ 2014-07-16 11:28 ` Sudeep Holla
2014-08-29 1:45 ` Alex Shi
0 siblings, 1 reply; 5+ messages in thread
From: Sudeep Holla @ 2014-07-16 11:28 UTC (permalink / raw)
To: Alex Shi, linux@arm.linux.org.uk
Cc: Sudeep Holla, Pawel Moll, nico@linaro.org,
viresh.kumar@linaro.org, rafael.j.wysocki@intel.com,
linux-kernel@vger.kernel.org, mark.brown@linaro.org,
tixy@linaro.org
Hi Alex,
On 16/07/14 12:21, Alex Shi wrote:
> With ARCH_VEXPRESS_SPC option, kernel build has the following
> warning:
>
> arch/arm/mach-vexpress/spc.c: In function ‘ve_spc_clk_init’:
> arch/arm/mach-vexpress/spc.c:431:38: warning: array subscript is below array bounds [-Warray-bounds]
> struct ve_spc_opp *opps = info->opps[cluster];
> ^
> since 'cluster' maybe '-1' in UP system. This patch does a active
> checking to fix this issue.
>
Good catch, looks fine to me.
Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> Signed-off-by: Alex Shi <alex.shi@linaro.org>
> ---
> arch/arm/mach-vexpress/spc.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
> index c26ef5b..4833544 100644
> --- a/arch/arm/mach-vexpress/spc.c
> +++ b/arch/arm/mach-vexpress/spc.c
> @@ -426,9 +426,15 @@ static int ve_spc_populate_opps(uint32_t cluster)
>
> static int ve_init_opp_table(struct device *cpu_dev)
> {
> - int cluster = topology_physical_package_id(cpu_dev->id);
> - int idx, ret = 0, max_opp = info->num_opps[cluster];
> - struct ve_spc_opp *opps = info->opps[cluster];
> + int cluster;
> + int idx, ret = 0, max_opp;
> + struct ve_spc_opp *opps;
> +
> + cluster = topology_physical_package_id(cpu_dev->id);
> + cluster = cluster < 0 ? 0 : cluster;
> +
> + max_opp = info->num_opps[cluster];
> + opps = info->opps[cluster];
>
> for (idx = 0; idx < max_opp; idx++, opps++) {
> ret = dev_pm_opp_add(cpu_dev, opps->freq * 1000, opps->u_volt);
> @@ -537,6 +543,8 @@ static struct clk *ve_spc_clk_register(struct device *cpu_dev)
> spc->hw.init = &init;
> spc->cluster = topology_physical_package_id(cpu_dev->id);
>
> + spc->cluster = spc->cluster < 0 ? 0 : spc->cluster;
> +
> init.name = dev_name(cpu_dev);
> init.ops = &clk_spc_ops;
> init.flags = CLK_IS_ROOT | CLK_GET_RATE_NOCACHE;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vexpress/spc: fix a build warning on array bounds
2014-07-16 11:28 ` Sudeep Holla
@ 2014-08-29 1:45 ` Alex Shi
2014-08-29 4:00 ` Pawel Moll
0 siblings, 1 reply; 5+ messages in thread
From: Alex Shi @ 2014-08-29 1:45 UTC (permalink / raw)
To: Sudeep Holla, linux@arm.linux.org.uk
Cc: Pawel Moll, nico@linaro.org, viresh.kumar@linaro.org,
rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org,
mark.brown@linaro.org, tixy@linaro.org
On 07/16/2014 07:28 PM, Sudeep Holla wrote:
>
>
> On 16/07/14 12:21, Alex Shi wrote:
>> With ARCH_VEXPRESS_SPC option, kernel build has the following
>> warning:
>>
>> arch/arm/mach-vexpress/spc.c: In function ‘ve_spc_clk_init’:
>> arch/arm/mach-vexpress/spc.c:431:38: warning: array subscript is below
>> array bounds [-Warray-bounds]
>> struct ve_spc_opp *opps = info->opps[cluster];
>> ^
>> since 'cluster' maybe '-1' in UP system. This patch does a active
>> checking to fix this issue.
>>
>
> Good catch, looks fine to me.
>
> Acked-by: Sudeep Holla <sudeep.holla@arm.com>
Anyone like to pick up this build warning fix? Or comments are appreciated!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vexpress/spc: fix a build warning on array bounds
2014-08-29 1:45 ` Alex Shi
@ 2014-08-29 4:00 ` Pawel Moll
2014-08-31 17:23 ` Olof Johansson
0 siblings, 1 reply; 5+ messages in thread
From: Pawel Moll @ 2014-08-29 4:00 UTC (permalink / raw)
To: Alex Shi, arm
Cc: Sudeep Holla, linux@arm.linux.org.uk, nico@linaro.org,
viresh.kumar@linaro.org, rafael.j.wysocki@intel.com,
linux-kernel@vger.kernel.org, mark.brown@linaro.org,
tixy@linaro.org
On pią, 2014-08-29 at 02:45 +0100, Alex Shi wrote:
> On 07/16/2014 07:28 PM, Sudeep Holla wrote:
> >
> >
> > On 16/07/14 12:21, Alex Shi wrote:
> >> With ARCH_VEXPRESS_SPC option, kernel build has the following
> >> warning:
> >>
> >> arch/arm/mach-vexpress/spc.c: In function ‘ve_spc_clk_init’:
> >> arch/arm/mach-vexpress/spc.c:431:38: warning: array subscript is below
> >> array bounds [-Warray-bounds]
> >> struct ve_spc_opp *opps = info->opps[cluster];
> >> ^
> >> since 'cluster' maybe '-1' in UP system. This patch does a active
> >> checking to fix this issue.
> >>
> >
> > Good catch, looks fine to me.
> >
> > Acked-by: Sudeep Holla <sudeep.holla@arm.com>
>
> Anyone like to pick up this build warning fix? Or comments are appreciated!
My fault, sorry, forgot about it...
Acked-by: Pawel Moll <pawel.moll@arm.com>
Arnd, Olof, could you please queue it as a fix? Happy to push a branch
if you wish.
Thanks!
Pawel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vexpress/spc: fix a build warning on array bounds
2014-08-29 4:00 ` Pawel Moll
@ 2014-08-31 17:23 ` Olof Johansson
0 siblings, 0 replies; 5+ messages in thread
From: Olof Johansson @ 2014-08-31 17:23 UTC (permalink / raw)
To: Pawel Moll
Cc: Alex Shi, arm, Sudeep Holla, linux@arm.linux.org.uk,
nico@linaro.org, viresh.kumar@linaro.org,
rafael.j.wysocki@intel.com, linux-kernel@vger.kernel.org,
mark.brown@linaro.org, tixy@linaro.org
On Thu, Aug 28, 2014 at 09:00:59PM -0700, Pawel Moll wrote:
> On pi??, 2014-08-29 at 02:45 +0100, Alex Shi wrote:
> > On 07/16/2014 07:28 PM, Sudeep Holla wrote:
> > >
> > >
> > > On 16/07/14 12:21, Alex Shi wrote:
> > >> With ARCH_VEXPRESS_SPC option, kernel build has the following
> > >> warning:
> > >>
> > >> arch/arm/mach-vexpress/spc.c: In function ???ve_spc_clk_init???:
> > >> arch/arm/mach-vexpress/spc.c:431:38: warning: array subscript is below
> > >> array bounds [-Warray-bounds]
> > >> struct ve_spc_opp *opps = info->opps[cluster];
> > >> ^
> > >> since 'cluster' maybe '-1' in UP system. This patch does a active
> > >> checking to fix this issue.
> > >>
> > >
> > > Good catch, looks fine to me.
> > >
> > > Acked-by: Sudeep Holla <sudeep.holla@arm.com>
> >
> > Anyone like to pick up this build warning fix? Or comments are appreciated!
>
> My fault, sorry, forgot about it...
>
> Acked-by: Pawel Moll <pawel.moll@arm.com>
>
> Arnd, Olof, could you please queue it as a fix? Happy to push a branch
> if you wish.
Applied. In the future, please feel free to just resend the patch
with the acked-bys added, no need to send a pull request for a single
patch. It's slightly more convenient to get a fresh copy of the patch
into arm@kernel.org folders, since now I had to go hunt it down on the
list it was originally posted.
-Olof
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-08-31 17:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-16 11:21 [PATCH] vexpress/spc: fix a build warning on array bounds Alex Shi
2014-07-16 11:28 ` Sudeep Holla
2014-08-29 1:45 ` Alex Shi
2014-08-29 4:00 ` Pawel Moll
2014-08-31 17:23 ` Olof Johansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox