net/af_xdp: fix unchecked return of recvfrom()

Message ID 20210325082209.29550-1-ciara.loftus@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/af_xdp: fix unchecked return of recvfrom() |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success travis build: passed
ci/github-robot success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Loftus, Ciara March 25, 2021, 8:22 a.m. UTC
  Coverity complains that the return value of recvfrom() in the AF_XDP
datapath is not checked. We don't care about the return value because in
the case of an error we still return 0 from the receive function to
indicate no packets were received. So to make Coverity happy we cast the
return to 'void'.

Coverity issue: 369671
Fixes: 63e8989fe5a4 ("net/af_xdp: use recvfrom instead of poll syscall")

Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Ferruh Yigit March 30, 2021, 1:50 p.m. UTC | #1
On 3/25/2021 8:22 AM, Ciara Loftus wrote:
> Coverity complains that the return value of recvfrom() in the AF_XDP
> datapath is not checked. We don't care about the return value because in
> the case of an error we still return 0 from the receive function to
> indicate no packets were received. So to make Coverity happy we cast the
> return to 'void'.
> 
> Coverity issue: 369671
> Fixes: 63e8989fe5a4 ("net/af_xdp: use recvfrom instead of poll syscall")
> 
> Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>

Applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index a64fef1cf5..6e44a21c64 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -274,7 +274,7 @@  af_xdp_rx_zc(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	if (nb_pkts == 0) {
 		if (syscall_needed(&rxq->fq, rxq->busy_budget))
-			recvfrom(xsk_socket__fd(rxq->xsk), NULL, 0,
+			(void)recvfrom(xsk_socket__fd(rxq->xsk), NULL, 0,
 				MSG_DONTWAIT, NULL, NULL);
 
 		return 0;
@@ -346,7 +346,7 @@  af_xdp_rx_cp(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	if (nb_pkts == 0) {
 #if defined(XDP_USE_NEED_WAKEUP)
 		if (xsk_ring_prod__needs_wakeup(fq))
-			recvfrom(xsk_socket__fd(rxq->xsk), NULL, 0,
+			(void)recvfrom(xsk_socket__fd(rxq->xsk), NULL, 0,
 				MSG_DONTWAIT, NULL, NULL);
 #endif
 		return 0;