From: Olivier Matz Date: Mon, 19 Sep 2016 12:26:51 +0000 (+0200) Subject: mem: fix build with -O1 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=11fd19f7646743c973b9de52d75120045e62f116;p=dpdk.git mem: fix build with -O1 When compiled with EXTRA_CFLAGS="-O1", the compiler is not able to detect that size is always initialized when used, and issues a wrong warning: eal_memory.c: In function ‘rte_eal_hugepage_attach’: eal_memory.c:1684:3: error: ‘size’ may be used uninitialized in this function [-Werror=maybe-uninitialized] munmap(hp, size); ^ Workaround this issue by initializing size to 0. Seen on gcc (Debian 5.4.1-1) 5.4.1 20160803. Signed-off-by: Olivier Matz --- diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index bb7a5a7600..a956bb226e 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1279,7 +1279,7 @@ rte_eal_hugepage_attach(void) unsigned num_hp = 0; unsigned i, s = 0; /* s used to track the segment number */ unsigned max_seg = RTE_MAX_MEMSEG; - off_t size; + off_t size = 0; int fd, fd_zero = -1, fd_hugepage = -1; if (aslr_enabled() > 0) {