From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tony Lu Subject: Re: [PATCH v3 04/12] eal: allow empty compile time flags Date: Thu, 9 Jul 2015 12:20:43 +0800 Message-ID: <001f01d0b9fe$a76ec2b0$f64c4810$@com> References: <1436172698-21749-1-git-send-email-zlu@ezchip.com> <1436172698-21749-5-git-send-email-zlu@ezchip.com> <8813269.8bcvtOYP9E@xps13> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org To: 'Thomas Monjalon' Return-path: Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1on0099.outbound.protection.outlook.com [157.56.112.99]) by dpdk.org (Postfix) with ESMTP id 8910E5A51 for ; Thu, 9 Jul 2015 06:21:01 +0200 (CEST) In-Reply-To: <8813269.8bcvtOYP9E@xps13> Content-Language: zh-cn List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" >-----Original Message----- >From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] >Sent: Thursday, July 09, 2015 8:46 AM >To: Zhigang Lu >Cc: dev@dpdk.org >Subject: Re: [dpdk-dev] [PATCH v3 04/12] eal: allow empty compile time flags > >2015-07-06 16:51, Zhigang Lu: >> The rte_cpu_check_supported() code breaks with a "comparison is always >> false due to limited range of data type" when the compile_time_flags[] >> array is empty. Assigning the array dimension to a local variable >> apparently solves this. > >How is it related to the title "allow empty compile time flags"? Changed the title and commit log a little bit as follows. eal: allow empty compile time flags RTE_COMPILE_TIME_CPUFLAGS When RTE_COMPILE_TIME_CPUFLAGS is empty, the rte_cpu_check_supported() code breaks with a "comparison is always false due to limited range of data type". This is because the compile_time_flags[] array is empty. Assigning the array dimension to a local variable apparently solves this. > >> - unsigned i; >> + unsigned count = RTE_DIM(compile_time_flags), i; >> int ret; > >Please define a "const unsigned count =" here to improve readability. If define as a const unsigned count, we also get the following compiler warning. error: comparison of unsigned expression < 0 is always false > >> - for (i = 0; i < sizeof(compile_time_flags)/sizeof(compile_time_flags[0]); i++) >{ >> + for (i = 0; i < count; i++) { > >