Re: [PATCH v3 2/5] staging: et131x: drop packet when error occurs in et131x_tx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 22, 2013 at 4:57 PM, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> This is a lot of spaghetti.  Just write it like this:
>
>
>         if (adapter->tx_ring.used >= NUM_TCB)
>                 goto drop;
>         if (adapter->flags & FMP_ADAPTER_FAIL_SEND_MASK)
>                 goto drop;
>         if (!netif_carrier_ok(netdev))
>                 goto drop;
>         status = send_packet(skb, adapter);
>         if (status)
>                 goto drop;
>
>         return NETDEV_TX_OK;
>
> drop:
>         dev_kfree_skb_any(skb);
>         adapter->net_stats.tx_dropped++;
>
>         /* We return success deliberately to make the netif layer happy */
>         return NETDEV_TX_OK;
>
> In the original code the success path was if condition false, then if
> condition true, then follow a goto then return.  In the new code it is
> straight line path to success with no nested if else statements.
>

This made the code more clear, I will apply it in resent patch. Thanks
for your review.
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux