From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 77CC2A058A; Fri, 17 Apr 2020 10:25:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 327881DE91; Fri, 17 Apr 2020 10:25:39 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 54FBE1DE86 for ; Fri, 17 Apr 2020 10:25:37 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03H8PEiZ027696; Fri, 17 Apr 2020 01:25:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0818; bh=fCf2r5Rq5ODvqwZAO5OQGSSklxi2KDhghlLwHo8IG9s=; b=Lv6td8g1XI09Nhhr+HiahEr4alwROMHTy8tF31Z00v16oTKfomT5w5+9n3/li/R9JbJA GpHshb9bEe+7T/bJP2hxBwSIydcm/ALqgj1IwC3Tn1h/SHoi03wnKaEaXX/V+EyANuO9 VZUKSqYF/LwDtlx1Uwt9D9P/aqBkJkTeRtP7Enu2l9J6lqxFEsBQL5NuEmgpZmFThNTd Qc6aqH0vkJHOkFBcey6N+rREmBwGDgtdDGEjZwKKgNAjk55tW5bBqy6rfO+eeguWuRwB 2bWwTXpCVu9rUNIKUyyuiJrDSJukFM/FyaM2sutz14ouC0HEFGBnTe42Pgy3aVxMgtdT 4Q== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 30dn8gu9x7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2020 01:25:36 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 17 Apr 2020 01:25:34 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 17 Apr 2020 01:25:35 -0700 Received: from localhost.localdomain (unknown [10.28.34.200]) by maili.marvell.com (Postfix) with ESMTP id 34ED43F7040; Fri, 17 Apr 2020 01:25:30 -0700 (PDT) From: Sunil Kumar Kori To: Jerin Jacob , Marko Kovacevic , Ori Kam , Bruce Richardson , Radu Nicolau , "Akhil Goyal" , Tomasz Kantecki , Sunil Kumar Kori , Pavan Nikhilesh CC: Date: Fri, 17 Apr 2020 13:55:16 +0530 Message-ID: <20200417082516.28803-1-skori@marvell.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-17_03:2020-04-14, 2020-04-17 signatures=0 Subject: [dpdk-dev] [PATCH] examples/l3fwd: fix error checking 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" Patch fixes coverity issues which handle return values from AP calling. Coverity issue: 354227, 354232, 354238, 354239, 354240 Fixes: aaf58cb85b62 ("examples/l3fwd: add event port and queue setup") Signed-off-by: Sunil Kumar Kori --- examples/l3fwd/l3fwd_event.c | 6 +++++- examples/l3fwd/l3fwd_event_generic.c | 9 +++++++-- examples/l3fwd/l3fwd_event_internal_port.c | 10 ++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/examples/l3fwd/l3fwd_event.c b/examples/l3fwd/l3fwd_event.c index 43c47eade..4d31593a0 100644 --- a/examples/l3fwd/l3fwd_event.c +++ b/examples/l3fwd/l3fwd_event.c @@ -70,7 +70,11 @@ l3fwd_eth_dev_port_setup(struct rte_eth_conf *port_conf) printf("Creating queues: nb_rxq=%d nb_txq=1...\n", evt_rsrc->eth_rx_queues); - rte_eth_dev_info_get(port_id, &dev_info); + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) + rte_panic("Error during getting device (port %u) info:" + "%s\n", port_id, strerror(-ret)); + if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; diff --git a/examples/l3fwd/l3fwd_event_generic.c b/examples/l3fwd/l3fwd_event_generic.c index c69c611dd..f8c98435d 100644 --- a/examples/l3fwd/l3fwd_event_generic.c +++ b/examples/l3fwd/l3fwd_event_generic.c @@ -101,7 +101,9 @@ l3fwd_event_port_setup_generic(void) rte_panic("No space is available\n"); memset(&def_p_conf, 0, sizeof(struct rte_event_port_conf)); - rte_event_port_default_conf_get(event_d_id, 0, &def_p_conf); + ret = rte_event_port_default_conf_get(event_d_id, 0, &def_p_conf); + if (ret < 0) + rte_panic("Error to get default configuration of event port\n"); if (def_p_conf.new_event_threshold < event_p_conf.new_event_threshold) event_p_conf.new_event_threshold = @@ -161,7 +163,10 @@ l3fwd_event_queue_setup_generic(uint32_t event_queue_cfg) if (!evt_rsrc->evq.event_q_id) rte_panic("Memory allocation failure\n"); - rte_event_queue_default_conf_get(event_d_id, 0, &def_q_conf); + ret = rte_event_queue_default_conf_get(event_d_id, 0, &def_q_conf); + if (ret < 0) + rte_panic("Error to get default config of event queue\n"); + if (def_q_conf.nb_atomic_flows < event_q_conf.nb_atomic_flows) event_q_conf.nb_atomic_flows = def_q_conf.nb_atomic_flows; diff --git a/examples/l3fwd/l3fwd_event_internal_port.c b/examples/l3fwd/l3fwd_event_internal_port.c index 993e26f13..03ac581d6 100644 --- a/examples/l3fwd/l3fwd_event_internal_port.c +++ b/examples/l3fwd/l3fwd_event_internal_port.c @@ -99,7 +99,10 @@ l3fwd_event_port_setup_internal_port(void) if (!evt_rsrc->evp.event_p_id) rte_panic("Failed to allocate memory for Event Ports\n"); - rte_event_port_default_conf_get(event_d_id, 0, &def_p_conf); + ret = rte_event_port_default_conf_get(event_d_id, 0, &def_p_conf); + if (ret < 0) + rte_panic("Error to get default configuration of event port\n"); + if (def_p_conf.new_event_threshold < event_p_conf.new_event_threshold) event_p_conf.new_event_threshold = def_p_conf.new_event_threshold; @@ -150,7 +153,10 @@ l3fwd_event_queue_setup_internal_port(uint32_t event_queue_cfg) uint8_t event_q_id = 0; int32_t ret; - rte_event_queue_default_conf_get(event_d_id, event_q_id, &def_q_conf); + ret = rte_event_queue_default_conf_get(event_d_id, event_q_id, + &def_q_conf); + if (ret < 0) + rte_panic("Error to get default config of event queue\n"); if (def_q_conf.nb_atomic_flows < event_q_conf.nb_atomic_flows) event_q_conf.nb_atomic_flows = def_q_conf.nb_atomic_flows; -- 2.17.1