diff mbox series

[v2,4/4] net/virtio: remove useless pointers checks

Message ID 20190605081005.15716-5-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers show
Series net/virtio: Fix packet segmentation bug | expand

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues

Commit Message

Maxime Coquelin June 5, 2019, 8:10 a.m. UTC
This patch removes uses checks on 'prev' pointer, as it
is always set before with a valid value.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 drivers/net/virtio/virtio_rxtx.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

Comments

David Marchand June 5, 2019, 9:35 a.m. UTC | #1
On Wed, Jun 5, 2019 at 10:11 AM Maxime Coquelin <maxime.coquelin@redhat.com>
wrote:

> This patch removes uses checks on 'prev' pointer, as it
> is always set before with a valid value.
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  drivers/net/virtio/virtio_rxtx.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/virtio/virtio_rxtx.c
> b/drivers/net/virtio/virtio_rxtx.c
> index 33dbc78906..fabd2e31d5 100644
> --- a/drivers/net/virtio/virtio_rxtx.c
> +++ b/drivers/net/virtio/virtio_rxtx.c
> @@ -1517,9 +1517,7 @@ virtio_recv_pkts_inorder(void *rx_queue,
>
>                         rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]);
>
> -                       if (prev)
> -                               prev->next = rxm;
> -
> +                       prev->next = rxm;
>                         prev = rxm;
>                         seg_res -= 1;
>                 }
> @@ -1703,9 +1701,7 @@ virtio_recv_mergeable_pkts(void *rx_queue,
>                         rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]);
>                         rx_pkts[nb_rx]->data_len += (uint16_t)(len[i]);
>
> -                       if (prev)
> -                               prev->next = rxm;
> -
> +                       prev->next = rxm;
>                         prev = rxm;
>                         seg_res -= 1;
>                 }
> @@ -1879,9 +1875,7 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue,
>                         rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]);
>                         rx_pkts[nb_rx]->data_len += (uint16_t)(len[i]);
>
> -                       if (prev)
> -                               prev->next = rxm;
> -
> +                       prev->next = rxm;
>                         prev = rxm;
>                         seg_res -= 1;
>                 }
> @@ -1924,8 +1918,7 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue,
>                 } else {
>                         PMD_RX_LOG(ERR,
>                                         "No enough segments for packet.");
> -                       if (prev)
> -                               virtio_discard_rxbuf(vq, prev);
> +                       virtio_discard_rxbuf(vq, prev);
>                         rxvq->stats.errors++;
>                         break;
>                 }
> --
> 2.21.0
>
>
Reviewed-by: David Marchand <david.marchand@redhat.com>
diff mbox series

Patch

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 33dbc78906..fabd2e31d5 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -1517,9 +1517,7 @@  virtio_recv_pkts_inorder(void *rx_queue,
 
 			rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]);
 
-			if (prev)
-				prev->next = rxm;
-
+			prev->next = rxm;
 			prev = rxm;
 			seg_res -= 1;
 		}
@@ -1703,9 +1701,7 @@  virtio_recv_mergeable_pkts(void *rx_queue,
 			rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]);
 			rx_pkts[nb_rx]->data_len += (uint16_t)(len[i]);
 
-			if (prev)
-				prev->next = rxm;
-
+			prev->next = rxm;
 			prev = rxm;
 			seg_res -= 1;
 		}
@@ -1879,9 +1875,7 @@  virtio_recv_mergeable_pkts_packed(void *rx_queue,
 			rx_pkts[nb_rx]->pkt_len += (uint32_t)(len[i]);
 			rx_pkts[nb_rx]->data_len += (uint16_t)(len[i]);
 
-			if (prev)
-				prev->next = rxm;
-
+			prev->next = rxm;
 			prev = rxm;
 			seg_res -= 1;
 		}
@@ -1924,8 +1918,7 @@  virtio_recv_mergeable_pkts_packed(void *rx_queue,
 		} else {
 			PMD_RX_LOG(ERR,
 					"No enough segments for packet.");
-			if (prev)
-				virtio_discard_rxbuf(vq, prev);
+			virtio_discard_rxbuf(vq, prev);
 			rxvq->stats.errors++;
 			break;
 		}