[ovs-dev] [PATCH v2 04/12] netdev-bsd: Use DP_PACKET_BATCH_FOR_EACH in netdev_bsd_send.

Ben Pfaff blp at ovn.org
Fri Nov 3 20:23:00 UTC 2017


On Wed, Sep 20, 2017 at 02:12:53PM +0100, Bhanuprakash Bodireddy wrote:
> Use DP_PACKET_BATCH_FOR_EACH macro in netdev_bsd_send().
> 
> Signed-off-by: Bhanuprakash Bodireddy <bhanuprakash.bodireddy at intel.com>
> ---
>  lib/netdev-bsd.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c
> index 8a4cdb3..96ba71c 100644
> --- a/lib/netdev-bsd.c
> +++ b/lib/netdev-bsd.c
> @@ -685,6 +685,7 @@ netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED,
>  {
>      struct netdev_bsd *dev = netdev_bsd_cast(netdev_);
>      const char *name = netdev_get_name(netdev_);
> +    struct dp_packet *packet;
>      int error;
>      int i;
>  
> @@ -695,9 +696,9 @@ netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED,
>          error = 0;
>      }
>  
> -    for (i = 0; i < batch->count; i++) {
> -        const void *data = dp_packet_data(batch->packets[i]);
> -        size_t size = dp_packet_get_send_len(batch->packets[i]);
> +    DP_PACKET_BATCH_FOR_EACH (packet, batch) {
> +        const void *data = dp_packet_data(packet);
> +        size_t size = dp_packet_get_send_len(packet);

It looks to me like this produces a duplicate variable named 'i' in an
inner scope, probably leaving the outer 'i' unused.

(I guess that DP_PACKET_BATCH_FOR_EACH should use a name other than 'i',
which has to be one of the most common variable names it could possibly
use.)


More information about the dev mailing list