From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933784AbeB1RId (ORCPT ); Wed, 28 Feb 2018 12:08:33 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:46579 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933248AbeB1PuE (ORCPT ); Wed, 28 Feb 2018 10:50:04 -0500 X-Google-Smtp-Source: AG47ELt1YAQQKR7+BcarZoxH4uRoHk4Atc1i+YGt2kWoPkuCkLPl+Ga01mwEycAyqnGrOmMO4b+HFbdVzJeho9uBQL8= MIME-Version: 1.0 In-Reply-To: <20180227204243.GW21977@gate.crashing.org> References: <20180225172236.29650-1-malat@debian.org> <20180225172236.29650-2-malat@debian.org> <603d5335-6220-73f2-d902-b92bc74bc79e@c-s.fr> <20180227204243.GW21977@gate.crashing.org> From: Andy Shevchenko Date: Wed, 28 Feb 2018 17:50:03 +0200 Message-ID: Subject: Re: [PATCH 01/21] powerpc: Remove warning on array size when empty To: Segher Boessenkool Cc: Mathieu Malaterre , "open list:LINUX FOR POWERPC PA SEMI PWRFICIENT" , Paul Mackerras , Linux Kernel Mailing List , Jiri Slaby Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 27, 2018 at 10:42 PM, Segher Boessenkool wrote: > On Tue, Feb 27, 2018 at 05:52:06PM +0200, Andy Shevchenko wrote: >> On Tue, Feb 27, 2018 at 9:44 AM, Mathieu Malaterre wrote: >> > On Tue, Feb 27, 2018 at 8:33 AM, Christophe LEROY >> > wrote: >> >> >>>>> Much simpler is just add >> >>>>> >> >>>>> if (ARRAY_SIZE() == 0) >> >>>>> return; >> >> >> 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. >> >> Did you run tests? Did you look into object file? >> >> In kernel we much rely on the compiling away the code which is >> deterministically not in use. >> Here I'm pretty sure it will compile away entire function. > > It does, but it also still warns (this warning is done very early in the > compiler pipeline). Oh, I see. Then the while () approach looks to me the best here. -- With Best Regards, Andy Shevchenko