[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vdpdr-0-vdvo0SBx2XcM=HePrUbbb4SM9+ExT_i-1B69Q@mail.gmail.com>
Date: Mon, 26 Feb 2018 16:44:25 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Mathieu Malaterre <malat@...ian.org>
Cc: Michael Ellerman <mpe@...erman.id.au>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
Jiri Slaby <jslaby@...e.com>,
"open list:LINUX FOR POWERPC PA SEMI PWRFICIENT"
<linuxppc-dev@...ts.ozlabs.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 01/21] powerpc: Remove warning on array size when empty
On Sun, Feb 25, 2018 at 7:22 PM, Mathieu Malaterre <malat@...ian.org> wrote:
> When neither CONFIG_ALTIVEC, nor CONFIG_VSX or CONFIG_PPC64 is defined, the
> array feature_properties is defined as an empty array, which in turn
> triggers the following warning (treated as error on W=1):
>
> CC arch/powerpc/kernel/prom.o
> arch/powerpc/kernel/prom.c: In function ‘check_cpu_feature_properties’:
> arch/powerpc/kernel/prom.c:298:16: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
> for (i = 0; i < ARRAY_SIZE(feature_properties); ++i, ++fp) {
> ^
> cc1: all warnings being treated as errors
>
> Signed-off-by: Mathieu Malaterre <malat@...ian.org>
> ---
> arch/powerpc/kernel/prom.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index 4dffef947b8a..6e8e4122820e 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -291,11 +291,10 @@ static inline void identical_pvr_fixup(unsigned long node)
>
> static void __init check_cpu_feature_properties(unsigned long node)
> {
> - unsigned long i;
> struct feature_property *fp = feature_properties;
> const __be32 *prop;
>
Much simpler is just add
if (ARRAY_SIZE() == 0)
return;
> - for (i = 0; i < ARRAY_SIZE(feature_properties); ++i, ++fp) {
> + for (; fp != feature_properties + ARRAY_SIZE(feature_properties); ++fp) {
> prop = of_get_flat_dt_prop(node, fp->name, NULL);
> if (prop && be32_to_cpup(prop) >= fp->min_value) {
> cur_cpu_spec->cpu_features |= fp->cpu_feature;
> --
> 2.11.0
>
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists