From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andriy Berestovskyy Subject: [PATCH 4/5] port: fix file descriptor reader Date: Fri, 31 Mar 2017 15:36:35 +0200 Message-ID: <1490967396-2240-4-git-send-email-Andriy.Berestovskyy@caviumnetworks.com> References: <1490967396-2240-1-git-send-email-Andriy.Berestovskyy@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: dev@dpdk.org To: Cristian Dumitrescu Return-path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0069.outbound.protection.outlook.com [104.47.38.69]) by dpdk.org (Postfix) with ESMTP id 243A12B98 for ; Fri, 31 Mar 2017 15:37:02 +0200 (CEST) In-Reply-To: <1490967396-2240-1-git-send-email-Andriy.Berestovskyy@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The code should return the actual number of packets read. Fixes: 5a99f208 ("port: support file descriptor") Signed-off-by: Andriy Berestovskyy --- lib/librte_port/rte_port_fd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/librte_port/rte_port_fd.c b/lib/librte_port/rte_port_fd.c index 03e69f5..914dfac 100644 --- a/lib/librte_port/rte_port_fd.c +++ b/lib/librte_port/rte_port_fd.c @@ -108,7 +108,7 @@ static int rte_port_fd_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { struct rte_port_fd_reader *p = (struct rte_port_fd_reader *) port; - uint32_t i; + uint32_t i, j; if (rte_pktmbuf_alloc_bulk(p->mempool, pkts, n_pkts) != 0) return 0; @@ -126,12 +126,12 @@ rte_port_fd_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) pkt->pkt_len = n_bytes; } - for ( ; i < n_pkts; i++) - rte_pktmbuf_free(pkts[i]); + for (j = i; j < n_pkts; j++) + rte_pktmbuf_free(pkts[j]); RTE_PORT_FD_READER_STATS_PKTS_IN_ADD(p, i); - return n_pkts; + return i; } static int -- 2.7.4