Obvious bug in /sys/i386/include/bus.h (was: bus_at386.h)
Joerg Sonnenberger
joerg at britannica.bec.de
Mon Jun 13 18:31:11 GMT 2005
On Mon, Jun 13, 2005 at 05:58:24PM +0200, Hans Petter Selasky wrote:
> static void
> filter(struct fifo *f)
> {
> do {
> if(!f->len)
> {
> if(f->m) ...;
>
> f->m = get_mbuf();
> if(!f->m) break;
>
> f->len = m->m_len;
> f->ptr = m->m_data;
> }
>
> /* f->Z_chip is the maximum transfer length */
>
> io_len = min(f->len, f->Z_chip);
if (io_len == 0)
continue;
>
> bus_space_write_multi_1(t,h,xxx,f->ptr,io_len);
>
> f->len -= io_len;
> f->Z_chip -= io_len;
> f->ptr += io_len;
>
> } while(Z_chip);
> }
>
[...]
> Adding that extra check for zero transfer length is not going to affect
> performance at all. If one does that using "C", the compiler can optimize
> away that "if(count) ..." when "count" is a constant. Besides the i386
> machine instructions "ins" and "outs" already exhibit that behaviour.
The compiler can only optimize it away if it is known to be a constant.
But thinking again about it, it should be documented at least whether
a count of 0 is allowed or not. I think it makes more sense to not allow
it, but others (you included) might disagree.
Joerg
More information about the freebsd-hackers
mailing list