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 01A41A04C7; Tue, 26 Nov 2019 04:28:37 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 491A42B88; Tue, 26 Nov 2019 04:28:37 +0100 (CET) Received: from mail-il1-f194.google.com (mail-il1-f194.google.com [209.85.166.194]) by dpdk.org (Postfix) with ESMTP id D63CA28EE for ; Tue, 26 Nov 2019 04:28:35 +0100 (CET) Received: by mail-il1-f194.google.com with SMTP id p6so16320730ilp.1 for ; Mon, 25 Nov 2019 19:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2SDgWQ9kazW4CyzUX9d9TEI7FM45vQyv+EQiHhzEcBc=; b=iWm9pmfGaUWl35kgrC6k2xTGoc8dnM8lbCDHzEHNKv1fw4ne24aevD+3S/EZ1IX6O5 N5iNPzqQrayNsYJWf85GZW0tf7B/Gp5XlfbRMR6rgHNUMXva9J2y+oA+/x37uQqcMtSs fTAwDAErmO1+zKZDvXGU2CFMxoQdG8mLVdYsabSPyzRJByiX3b7YVTneXZslgys0ja71 w88tafgqCS22vpmtR/GLhMYZ999IBZmnHr+AJ6qoqx/kGmibGOAPe1Ynff1D1aZ5huHy vyxFMzm4BDnO6RhiUVSpRBenaeEgCNmDJZG6DOyVdlqWEI4O4BMlQunaAwzpHhYzs7Q7 +nUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2SDgWQ9kazW4CyzUX9d9TEI7FM45vQyv+EQiHhzEcBc=; b=eZ9PFzk5kUExNl8//q/NwpHcod68+oUurKudZx6xqZhy2C0IMzAFobnHm7Q58Z2Rbs DzIrZjxEhICm6mfeXnm4SNwvxqwK2QcpFAhQhIdSGRHuTmJDCioP75ImN34Uj/WvIVSu o5MLFGvR9vzQm907bwE85xq06Fj/ThCDaF8wGS0lMfCpQz7Xf4xEt9rVZF5wG5M9GWIO beHN4Xo6BXJ5OY5/Ra5D7koTNYvYoPifNiYFFebBGXF4lFq/8g/atr6XG/U4jq+I65He 44IrcFpiEQvo+QpMeIZSTvokXMqIdoKmSjI7L27on8zf6ew2RBEBypBAzvPUFhKTtQo1 V2Iw== X-Gm-Message-State: APjAAAXfOT5NojE9S7nyL25DVvXi7TNIZW046cwpfLQtTfBY+ShQ3iRA gM2r537n4Qr8PdkaKNZbn90e6mgtC34Vw/3zjCQ= X-Google-Smtp-Source: APXvYqxjc8FPngqXnBrfW014ilviBGRUyZaNaNiEHwmFVAOhGfCwY04GK8Fuwm300juJxuX8PYRUohXZz0WJw/4Zzvo= X-Received: by 2002:a92:4b07:: with SMTP id m7mr36430985ilg.271.1574738914967; Mon, 25 Nov 2019 19:28:34 -0800 (PST) MIME-Version: 1.0 References: <20191121182718.7851-1-pbhagavatula@marvell.com> In-Reply-To: <20191121182718.7851-1-pbhagavatula@marvell.com> From: Jerin Jacob Date: Tue, 26 Nov 2019 12:28:19 +0900 Message-ID: To: Pavan Nikhilesh Cc: Jerin Jacob , Marko Kovacevic , Ori Kam , Bruce Richardson , Radu Nicolau , Akhil Goyal , Tomasz Kantecki , Sunil Kumar Kori , dpdk-dev Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH 1/2] examples/l2fwd-event: validate function return values 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" On Fri, Nov 22, 2019 at 3:27 AM wrote: > > From: Pavan Nikhilesh > > Validate `rte_eth_link_get_nowait`, `rte_service_map_lcore_set` and > `rte_eth_dev_info_get` return values. > > Coverity issue: 350600 > Coverity issue: 350601 > Coverity issue: 350602 > > Signed-off-by: Pavan Nikhilesh Applied to dpdk-next-eventdev/master. Thanks. > --- > examples/l2fwd-event/l2fwd_common.c | 6 +++++- > examples/l2fwd-event/l2fwd_event.c | 7 ++++--- > examples/l2fwd-event/main.c | 10 +++++++++- > 3 files changed, 18 insertions(+), 5 deletions(-) > > diff --git a/examples/l2fwd-event/l2fwd_common.c b/examples/l2fwd-event/l2fwd_common.c > index 4ba788550..0c069ec35 100644 > --- a/examples/l2fwd-event/l2fwd_common.c > +++ b/examples/l2fwd-event/l2fwd_common.c > @@ -41,7 +41,11 @@ l2fwd_event_init_ports(struct l2fwd_resources *rsrc) > /* init port */ > printf("Initializing port %u... ", port_id); > fflush(stdout); > - 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/l2fwd-event/l2fwd_event.c b/examples/l2fwd-event/l2fwd_event.c > index c7782cbc5..0379c580d 100644 > --- a/examples/l2fwd-event/l2fwd_event.c > +++ b/examples/l2fwd-event/l2fwd_event.c > @@ -41,8 +41,9 @@ l2fwd_event_service_enable(uint32_t service_id) > /* Get the core which has least number of services running. */ > while (slcore_count--) { > /* Reset default mapping */ > - rte_service_map_lcore_set(service_id, > - slcore_array[slcore_count], 0); > + if (rte_service_map_lcore_set(service_id, > + slcore_array[slcore_count], 0) != 0) > + return -ENOENT; > service_count = rte_service_lcore_count_services( > slcore_array[slcore_count]); > if (service_count < min_service_count) { > @@ -50,7 +51,7 @@ l2fwd_event_service_enable(uint32_t service_id) > min_service_count = service_count; > } > } > - if (rte_service_map_lcore_set(service_id, slcore, 1)) > + if (rte_service_map_lcore_set(service_id, slcore, 1) != 0) > return -ENOENT; > rte_service_lcore_start(slcore); > > diff --git a/examples/l2fwd-event/main.c b/examples/l2fwd-event/main.c > index 142c00e8f..89a6bb9a4 100644 > --- a/examples/l2fwd-event/main.c > +++ b/examples/l2fwd-event/main.c > @@ -234,6 +234,7 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc, > uint16_t port_id; > uint8_t count, all_ports_up, print_flag = 0; > struct rte_eth_link link; > + int ret; > > printf("\nChecking link status..."); > fflush(stdout); > @@ -247,7 +248,14 @@ check_all_ports_link_status(struct l2fwd_resources *rsrc, > if ((port_mask & (1 << port_id)) == 0) > continue; > memset(&link, 0, sizeof(link)); > - rte_eth_link_get_nowait(port_id, &link); > + ret = rte_eth_link_get_nowait(port_id, &link); > + if (ret < 0) { > + all_ports_up = 0; > + if (print_flag == 1) > + printf("Port %u link get failed: %s\n", > + port_id, rte_strerror(-ret)); > + continue; > + } > /* print link status if flag set */ > if (print_flag == 1) { > if (link.link_status) > -- > 2.17.1 >