Subject: Re: [PATCH 2/2] macvlan: Move broadcasts into a work queue

From: Stephen Hemminger <[email-masked]>
Date: Tue, 8 Apr 2014 09:55:23 -0700

On Mon, 07 Apr 2014 15:55:36 +0800
Herbert Xu <[email-masked]> wrote:

> +static void macvlan_broadcast_enqueue(struct macvlan_port *port,
> +				      struct sk_buff *skb)
> +{
> +	int err = -ENOMEM;
> +
> +	skb = skb_clone(skb, GFP_ATOMIC);
> +	if (unlikely(!skb))
> +		goto err;
> +
> +	spin_lock(&port->bc_queue.lock);
> +	if (skb_queue_len(&port->bc_queue) < skb->dev->tx_queue_len) {
> +		__skb_queue_tail(&port->bc_queue, skb);
> +		err = 0;
> +	}
> +	spin_unlock(&port->bc_queue.lock);
> +
> +	if (unlikely(err)) {
> +err:
> +		atomic_long_inc(&skb->dev->rx_dropped);
> +		return;
> +	}
> +

unlikely() with goto is redundant and unnecessary.

IMHO jumping into a block is bad code style

Why not just move err: to the end as in:

	skb = skb_clone(skb, GFP_ATOMIC);
	if (unlikely(!skb))
		goto err;

	spin_lock(&port->bc_queue.lock);
	if (skb_queue_len(&port->bc_queue) < skb->dev->tx_queue_len) {
		__skb_queue_tail(&port->bc_queue, skb);
		err = 0;
	}
	spin_unlock(&port->bc_queue.lock);

	if (err)
		goto err;

	schedule_work(&port->bc_work);
	return;
err:

	atomic_long_inc(&skb->dev->rx_dropped);
}