From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by dpdk.org (Postfix) with ESMTP id D0F10C37C for ; Sat, 27 Jun 2015 02:01:42 +0200 (CEST) Received: by pactm7 with SMTP id tm7so75580970pac.2 for ; Fri, 26 Jun 2015 17:01:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bo8odvXz4BH32Qp63QiIukzU1fGWjNMyNh7inZnw3/g=; b=GfxJ0RI752oaVJ2MM7RHQknLdfWbjsq5NC9Ue+bBa9ZH5J3r5EK+O7z0N9Y0wI4A4p H1LkrIj5qNmIHZarluC2yd1qBhn5C/hw6q2Na4qYzoansClKt9yRhIFRMaaiouVCpWI9 IlclX/nLM5vLT+eqw3Y3Yr4KWe9MD44mVre9wuDzWCO+ky3rYa1FBO2FJZQfEIz37n/w vbZNoFILZWK4kxEpvgWKRoSrWwgeBWw0J0tC9ehNCbR8O8eBQv7hDoViGE1RPch/NUR8 9H74yEZhD6wYFyEeN2A0WJoRVOjc/a0LEY/Twq2g8skhdOzYoiCDNF6fYEUEjEGkf7lP BBGw== X-Gm-Message-State: ALoCoQn7D9NB80f5z+srzy2RqHzn3XN5N1oSBbG+jTu0XCkHSHYLcUTxNW14gSDfgKUwoAfSKJbQ X-Received: by 10.70.49.73 with SMTP id s9mr7931420pdn.149.1435363302074; Fri, 26 Jun 2015 17:01:42 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id de4sm34434549pbb.95.2015.06.26.17.01.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jun 2015 17:01:41 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Date: Fri, 26 Jun 2015 17:01:42 -0700 Message-Id: <1435363305-17819-2-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435363305-17819-1-git-send-email-stephen@networkplumber.org> References: <1435363305-17819-1-git-send-email-stephen@networkplumber.org> Cc: Stephen Hemminger Subject: [dpdk-dev] [PATCH 1/4] rte_ethdev: remove impossible condition 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: Sat, 27 Jun 2015 00:01:43 -0000 From: Stephen Hemminger Since rte_eth_devices is in BSS, the address of rte_eth_devices plus port_id can not ever be NULL for a valid port_id number. Remove this unnecessary check and fix the code style. Signed-off-by: Stephen Hemminger --- lib/librte_ether/rte_ethdev.c | 45 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 02cd07f..dec3da7 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -3290,10 +3290,7 @@ int rte_eth_dev_bypass_init(uint8_t port_id) return -ENODEV; } - if ((dev= &rte_eth_devices[port_id]) == NULL) { - PMD_DEBUG_TRACE("Invalid port device\n"); - return -ENODEV; - } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_init, -ENOTSUP); (*dev->dev_ops->bypass_init)(dev); @@ -3310,10 +3307,7 @@ rte_eth_dev_bypass_state_show(uint8_t port_id, uint32_t *state) return -ENODEV; } - if ((dev= &rte_eth_devices[port_id]) == NULL) { - PMD_DEBUG_TRACE("Invalid port device\n"); - return -ENODEV; - } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP); (*dev->dev_ops->bypass_state_show)(dev, state); return 0; @@ -3329,10 +3323,7 @@ rte_eth_dev_bypass_state_set(uint8_t port_id, uint32_t *new_state) return -ENODEV; } - if ((dev= &rte_eth_devices[port_id]) == NULL) { - PMD_DEBUG_TRACE("Invalid port device\n"); - return -ENODEV; - } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_set, -ENOTSUP); (*dev->dev_ops->bypass_state_set)(dev, new_state); @@ -3349,10 +3340,7 @@ rte_eth_dev_bypass_event_show(uint8_t port_id, uint32_t event, uint32_t *state) return -ENODEV; } - if ((dev= &rte_eth_devices[port_id]) == NULL) { - PMD_DEBUG_TRACE("Invalid port device\n"); - return -ENODEV; - } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_state_show, -ENOTSUP); (*dev->dev_ops->bypass_event_show)(dev, event, state); @@ -3369,10 +3357,7 @@ rte_eth_dev_bypass_event_store(uint8_t port_id, uint32_t event, uint32_t state) return -ENODEV; } - if ((dev= &rte_eth_devices[port_id]) == NULL) { - PMD_DEBUG_TRACE("Invalid port device\n"); - return -ENODEV; - } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_event_set, -ENOTSUP); (*dev->dev_ops->bypass_event_set)(dev, event, state); @@ -3389,10 +3374,7 @@ rte_eth_dev_wd_timeout_store(uint8_t port_id, uint32_t timeout) return -ENODEV; } - if ((dev= &rte_eth_devices[port_id]) == NULL) { - PMD_DEBUG_TRACE("Invalid port device\n"); - return -ENODEV; - } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_set, -ENOTSUP); (*dev->dev_ops->bypass_wd_timeout_set)(dev, timeout); @@ -3409,10 +3391,7 @@ rte_eth_dev_bypass_ver_show(uint8_t port_id, uint32_t *ver) return -ENODEV; } - if ((dev= &rte_eth_devices[port_id]) == NULL) { - PMD_DEBUG_TRACE("Invalid port device\n"); - return -ENODEV; - } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_ver_show, -ENOTSUP); (*dev->dev_ops->bypass_ver_show)(dev, ver); @@ -3429,10 +3408,7 @@ rte_eth_dev_bypass_wd_timeout_show(uint8_t port_id, uint32_t *wd_timeout) return -ENODEV; } - if ((dev= &rte_eth_devices[port_id]) == NULL) { - PMD_DEBUG_TRACE("Invalid port device\n"); - return -ENODEV; - } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_timeout_show, -ENOTSUP); (*dev->dev_ops->bypass_wd_timeout_show)(dev, wd_timeout); @@ -3449,10 +3425,7 @@ rte_eth_dev_bypass_wd_reset(uint8_t port_id) return -ENODEV; } - if ((dev= &rte_eth_devices[port_id]) == NULL) { - PMD_DEBUG_TRACE("Invalid port device\n"); - return -ENODEV; - } + dev = &rte_eth_devices[port_id]; FUNC_PTR_OR_ERR_RET(*dev->dev_ops->bypass_wd_reset, -ENOTSUP); (*dev->dev_ops->bypass_wd_reset)(dev); -- 2.1.4