9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: presotto@plan9.bell-labs.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] ether8139.c fix
Date: Thu,  7 Mar 2002 09:08:25 -0500	[thread overview]
Message-ID: <c375fdd1f9e99d3297783ffd139be38d@plan9.bell-labs.com> (raw)


<geoff@collyer.net> a crit dans le message news:<20020304000219.1ABC919999@mail.cse.psu.edu>...
> Line 494, in rtl8139receive(), reads
> 
> 				memmove(bp->rp, p, l);
> but should be
> 				memmove(bp->wp, p, l);
> 
> jmk has vetted this change.

This fix should be a noop.  Though the change should be made for
clarity, after the bp = iallocb(length), both bp->rp and
bp->wp point to the same spot.

However, looking at the code, if the packet wraps around the
buffer, and if the crc straddles the end of the ring buffer, the
code is just wrong.  It would be better as:

		bp = iallocb(length);
		if(p+length >= ctlr->rbstart+ctlr->rblen){
			l = ctlr->rbstart+ctlr->rblen - p;
			if(bp != nil){
				memmove(bp->rp, p, l);
				bp->wp += l;
			}
			length -= l;
			p = ctlr->rbstart;
		}
		if(length > 0 && bp != nil){
			memmove(bp->wp, p, length);
			bp->wp += length;
		}
		if(bp != nil){
			bp->wp -= 4;

One could rewrite the if-chain to be a bit more efficient, but
you should get the idea.

Of course, I'm assuming that the device allows the CRC to straddle
the end of the buffer.  If not, the code is fine as is.  However,
looking at memmove.s, it'll fault if the length is negative, which
I believe is the observed behaviour.


             reply	other threads:[~2002-03-07 14:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-07 14:08 presotto [this message]
2002-03-07 15:01 ` Boyd Roberts
  -- strict thread matches above, loose matches on Subject: below --
2002-03-07 17:59 jmk
2002-03-07  4:07 jmk
2002-03-07  4:07 Plan9
2002-03-07  3:14 geoff
2002-03-07  4:52 ` Jason Gurtz
2002-03-05 15:26 jmk
2002-03-04  0:00 geoff
2002-03-05  9:40 ` Don

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c375fdd1f9e99d3297783ffd139be38d@plan9.bell-labs.com \
    --to=presotto@plan9.bell-labs.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).