[dpdk-dev,v2,11/12] eal: allow empty set of compile time cpuflags

Message ID 1420527230-17037-12-git-send-email-zlu@ezchip.com (mailing list archive)
State Changes Requested, archived
Headers

Commit Message

Zhigang Lu Jan. 6, 2015, 6:53 a.m. UTC
  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 <zlu@ezchip.com>
Signed-off-by: Cyril Chemparathy <cchemparathy@ezchip.com>
---
 lib/librte_eal/common/eal_common_cpuflags.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Patch

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) {