From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zr9R92CnpzDrVr for ; Tue, 27 Feb 2018 18:33:24 +1100 (AEDT) Subject: Re: [PATCH 01/21] powerpc: Remove warning on array size when empty To: Mathieu Malaterre , Andy Shevchenko Cc: Linux Kernel Mailing List , Paul Mackerras , Jiri Slaby , "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" References: <20180225172236.29650-1-malat@debian.org> <20180225172236.29650-2-malat@debian.org> From: Christophe LEROY Message-ID: <603d5335-6220-73f2-d902-b92bc74bc79e@c-s.fr> Date: Tue, 27 Feb 2018 08:33:19 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Le 27/02/2018 à 08:25, Mathieu Malaterre a écrit : > 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 = 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) { >> >> ...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 != in the original form ? Or add in front: if (!ARRAY_SIZE(feature_properties)) return; Christophe