From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sclab-apps-2.localdomain (sc-fw1.tilera.com [12.218.212.162]) by dpdk.org (Postfix) with ESMTP id 29DDEC900 for ; Mon, 22 Jun 2015 20:58:46 +0200 (CEST) X-CheckPoint: {55885AE5-9-A3D4DA0C-C0000002} Received: by sclab-apps-2.localdomain (Postfix, from userid 1318) id 86A342204C7; Mon, 22 Jun 2015 11:58:45 -0700 (PDT) From: Cyril Chemparathy To: dev@dpdk.org Date: Mon, 22 Jun 2015 11:58:36 -0700 Message-Id: <1434999524-26528-5-git-send-email-cchemparathy@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1434999524-26528-1-git-send-email-cchemparathy@ezchip.com> References: <1434999524-26528-1-git-send-email-cchemparathy@ezchip.com> Subject: [dpdk-dev] [PATCH v2 04/12] eal: allow empty compile time flags X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jun 2015 18:58:56 -0000 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. Change-Id: I0ae21f529cf7b6dd9cf0f4532dce9198f4bf4230 Signed-off-by: Cyril Chemparathy --- lib/librte_eal/common/eal_common_cpuflags.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/eal_common_cpuflags.c b/lib/librte_eal/common/eal_common_cpuflags.c index 6fd360c..8ba7b30 100644 --- a/lib/librte_eal/common/eal_common_cpuflags.c +++ b/lib/librte_eal/common/eal_common_cpuflags.c @@ -30,6 +30,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include /* @@ -62,10 +63,10 @@ rte_cpu_check_supported(void) static const enum rte_cpu_flag_t compile_time_flags[] = { RTE_COMPILE_TIME_CPUFLAGS }; - unsigned i; + unsigned count = RTE_DIM(compile_time_flags), 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