at86rf2xx: move netstat increment after possible error return

This commit is contained in:
smlng 2016-10-21 21:57:32 +02:00
parent 89978ab8e5
commit 68c30b30e5

View File

@ -148,15 +148,15 @@ static int _recv(netdev2_t *netdev, void *buf, size_t len, void *info)
at86rf2xx_fb_stop(dev);
return pkt_len;
}
#ifdef MODULE_NETSTATS_L2
netdev->stats.rx_count++;
netdev->stats.rx_bytes += pkt_len;
#endif
/* not enough space in buf */
if (pkt_len > len) {
at86rf2xx_fb_stop(dev);
return -ENOBUFS;
}
#ifdef MODULE_NETSTATS_L2
netdev->stats.rx_count++;
netdev->stats.rx_bytes += pkt_len;
#endif
/* copy payload */
at86rf2xx_fb_read(dev, (uint8_t *)buf, pkt_len);