[dpdk-dev] [PATCH v2 4/4] net/virtio: remove useless pointers checks

David Marchand david.marchand at redhat.com
Wed Jun 5 11:35:04 CEST 2019


On Wed, Jun 5, 2019 at 10:11 AM Maxime Coquelin <maxime.coquelin at 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 at 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 at redhat.com>

-- 
David Marchand


More information about the dev mailing list