From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-x230.google.com (mail-vk0-x230.google.com [IPv6:2607:f8b0:400c:c05::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zr9gr4zmxzF1Cj for ; Tue, 27 Feb 2018 18:44:24 +1100 (AEDT) Received: by mail-vk0-x230.google.com with SMTP id s1so3878911vke.5 for ; Mon, 26 Feb 2018 23:44:24 -0800 (PST) MIME-Version: 1.0 Sender: mathieu.malaterre@gmail.com In-Reply-To: <603d5335-6220-73f2-d902-b92bc74bc79e@c-s.fr> References: <20180225172236.29650-1-malat@debian.org> <20180225172236.29650-2-malat@debian.org> <603d5335-6220-73f2-d902-b92bc74bc79e@c-s.fr> From: Mathieu Malaterre Date: Tue, 27 Feb 2018 08:44:01 +0100 Message-ID: Subject: Re: [PATCH 01/21] powerpc: Remove warning on array size when empty To: Christophe LEROY Cc: Andy Shevchenko , Linux Kernel Mailing List , Paul Mackerras , Jiri Slaby , "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" Content-Type: text/plain; charset="UTF-8" List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Tue, Feb 27, 2018 at 8:33 AM, Christophe LEROY wrote: > > > Le 27/02/2018 =C3=A0 08:25, Mathieu Malaterre a =C3=A9crit : >> >> On Mon, Feb 26, 2018 at 3:45 PM, Andy Shevchenko >> wrote: >>> >>> On Mon, Feb 26, 2018 at 4:44 PM, Andy Shevchenko >>> wrote: >>>> >>>> On Sun, Feb 25, 2018 at 7:22 PM, Mathieu Malaterre >>>> wrote: >>> >>> >>>>> static void __init check_cpu_feature_properties(unsigned long node) >>>>> { >>>>> - unsigned long i; >>>>> struct feature_property *fp =3D feature_properties; >>>>> const __be32 *prop; >>>>> >>>> >>>> Much simpler is just add >>>> >>>> if (ARRAY_SIZE() =3D=3D 0) >>>> return; >>>> >>>>> - for (i =3D 0; i < ARRAY_SIZE(feature_properties); ++i, ++fp) = { >>>>> + for (; fp !=3D feature_properties + >>>>> ARRAY_SIZE(feature_properties); ++fp) { >>> >>> >>> ...or convert to while(), which will be more readable. >> >> >> So you'd prefer something like: >> >> while (fp < feature_properties + ARRAY_SIZE(feature_properties)) { >> ... >> ++fp; >> } >> >> right ? >> > > > Why not do as suggested by Segher, ie just replace < by !=3D in the origi= nal > form ? I can do that. > Or add in front: > if (!ARRAY_SIZE(feature_properties)) > return; (not tested) I believe the compiler still go over the for() loop and will complain about the original unsigned comparison. > Christophe