From patchwork Thu Jul 6 21:45:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 26562 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id CA6812B96; Thu, 6 Jul 2017 23:45:42 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id BC43D1094 for ; Thu, 6 Jul 2017 23:45:40 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 36F6920B96; Thu, 6 Jul 2017 17:45:40 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Thu, 06 Jul 2017 17:45:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=ACTBswdpko4R+uKScLhNxiJOOZF cRPjbzFRkRbYuMQc=; b=jx2yW8IVwOiFSePm2yXcQttXq54UsBJG01x0rKFo7w6 hVMhk/vGzbM1LZ+5TLUtvbivQrSM3lY7qGKGC6SpVEdNjGFMgIgErDPdaf/WUplG Izskr67lj4DU3E4bVcxUFOziBwKxfLpWPKa5XxkMZSYFdZrEIclUrp+CpyJBoD4w = DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=ACTBsw dpko4R+uKScLhNxiJOOZFcRPjbzFRkRbYuMQc=; b=VR7klEJykeQlJkf1z+em9L VNTie5HTiOi6k7ojdxR00seKDlAj21rgBgferJkwOaeRiVCIC6aoxdVoWHB6yZCQ QdUBuumu55LGO2QG0nGa8FY6onXdwiamkA9HV47vwV8AzUjPX2f8Km7DiJtKifhy Y/ih+8xZg0bYESAfBI1Ur5nOD9H5MzsK/ufQzlhbQgrQ3HcuGn/y+pbfrVIoJl8k RpyLS+D0NVG3GF9OY/+XLDBMTRGQUiqERTK9K1D40J559vsCuNkfZdZ062OWU9Ef W+F95K0CREGxNAhaZXfwK+XYbs6k6HWHr2Jy3Y1hiqdAKfwnYZxIpjIqmQmcX1HA == X-ME-Sender: X-Sasl-enc: afuQQA+NrmQ6uYB1tibQw+3XnbU6MJVv72PsX3WiWJAP 1499377539 Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 9B8B224788; Thu, 6 Jul 2017 17:45:39 -0400 (EDT) From: Thomas Monjalon To: Matan Azrad Cc: dev@dpdk.org Date: Thu, 6 Jul 2017 23:45:32 +0200 Message-Id: <20170706214532.31274-1-thomas@monjalon.net> X-Mailer: git-send-email 2.13.1 Subject: [dpdk-dev] [PATCH] ethdev: fix build with gcc 5.4.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Seen on Ubuntu 16.04 with GCC 5.4.0: lib/librte_ether/rte_ethdev.c: In function 'get_mac_addr_index': lib/librte_ether/rte_ethdev.c:2369:26: error: 'dev_info.max_mac_addrs' may be used uninitialized in this function Indeed, rte_eth_dev_info_get() do not write into dev_info if the port_id is not valid. So we need to check the port_id and return in case of error. This extra check should not be needed because the port_id is always checked before calling get_mac_addr_index(). However it does not hurt. Reported-by: Matan Azrad Signed-off-by: Thomas Monjalon Tested-by: Matan Azrad --- lib/librte_ether/rte_ethdev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 957ae2a17..b038f281b 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -2357,6 +2357,7 @@ get_mac_addr_index(uint8_t port_id, const struct ether_addr *addr) struct rte_eth_dev *dev = &rte_eth_devices[port_id]; unsigned i; + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); rte_eth_dev_info_get(port_id, &dev_info); for (i = 0; i < dev_info.max_mac_addrs; i++)