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 at ezchip.com> Signed-off-by: Cyril Chemparathy <cchemparathy at ezchip.com> --- 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