From 876c3202b22f6656b7954210b70ad0c6a863ea88 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 8 Mar 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-03-08 --- pc/ether8139.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/pc/ether8139.c b/pc/ether8139.c index 2c5bdbef621e9832cc659128e8c2394bb4e62783..57bba1355c440c5cfd12f5965834ed5197c9831e 100644 --- a/pc/ether8139.c +++ b/pc/ether8139.c @@ -487,29 +487,24 @@ rtl8139receive(Ether* edev) p = ctlr->rbstart+capr; capr = (capr+length) % ctlr->rblen; - bp = iallocb(length); - if(p+length >= ctlr->rbstart+ctlr->rblen){ - l = ctlr->rbstart+ctlr->rblen - p; - if(bp != nil){ - memmove(bp->rp, p, l); + if((bp = iallocb(length)) != nil){ + if(p+length >= ctlr->rbstart+ctlr->rblen){ + l = ctlr->rbstart+ctlr->rblen - p; + memmove(bp->wp, p, l); bp->wp += l; - if(l == length) - bp->wp -= 4; + length -= l; + p = ctlr->rbstart; } - length -= l; - p = ctlr->rbstart; - } - if(length > 0 && bp != nil){ - length -= 4; - memmove(bp->wp, p, length); - bp->wp += length; + if(length > 0){ + memmove(bp->wp, p, length); + bp->wp += length; + } + bp->wp -= 4; + etheriq(edev, bp, 1); } capr = ROUNDUP(capr, 4); csr16w(ctlr, Capr, capr-16); - - if(bp != nil) - etheriq(edev, bp, 1); } }