From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zhigang Lu Subject: [PATCH v2 11/12] eal: allow empty set of compile time cpuflags Date: Tue, 6 Jan 2015 14:53:49 +0800 Message-ID: <1420527230-17037-12-git-send-email-zlu@ezchip.com> References: <1420527230-17037-1-git-send-email-zlu@ezchip.com> Mime-Version: 1.0 Content-Type: text/plain To: Return-path: In-Reply-To: <1420527230-17037-1-git-send-email-zlu-d5a29ZRxExrQT0dZR+AlfA@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" On architectures that do not rely on RTE_COMPILE_TIME_CPUFLAGS, the compile_time_flags[] array can end up being zero sized. This results in a compiler complaint in the subsequent loop. Pulling out the array size computation silences this complaint. Signed-off-by: Zhigang Lu Signed-off-by: Cyril Chemparathy --- lib/librte_eal/common/eal_common_cpuflags.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c index 6fd360c..7a1ca26 100644 --- a/lib/librte_eal/common/eal_common_cpuflags.c +++ b/lib/librte_eal/common/eal_common_cpuflags.c @@ -62,10 +62,12 @@ rte_cpu_check_supported(void) static const enum rte_cpu_flag_t compile_time_flags[] = { RTE_COMPILE_TIME_CPUFLAGS }; + unsigned count = + sizeof(compile_time_flags)/sizeof(compile_time_flags[0]); unsigned i; int ret; - for (i = 0; i < sizeof(compile_time_flags)/sizeof(compile_time_flags[0]); i++) { + for (i = 0; i < count; i++) { ret = rte_cpu_get_flag_enabled(compile_time_flags[i]); if (ret < 0) { -- 2.1.2