From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 43D38374F for ; Mon, 19 Sep 2016 14:27:18 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 0BE5E25A16; Mon, 19 Sep 2016 14:27:18 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org, sergio.gonzalez.monroy@intel.com Date: Mon, 19 Sep 2016 14:26:51 +0200 Message-Id: <1474288011-17096-1-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] eal: fix compilation when optimization level is O1 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, 19 Sep 2016 12:27:18 -0000 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 --- lib/librte_eal/linuxapp/eal/eal_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index 992a1b1..4697fef 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -1545,7 +1545,7 @@ rte_eal_hugepage_attach(void) struct hugepage_file *hp = NULL; unsigned num_hp = 0; unsigned i, s = 0; /* s used to track the segment number */ - off_t size; + off_t size = 0; int fd, fd_zero = -1, fd_hugepage = -1; if (aslr_enabled() > 0) { -- 2.8.1