Subject: Re: Last remaining insque / remque uses
To: NetBSD tech-kern mailing list <tech-kern@NetBSD.org>
From: David Young <dyoung@pobox.com>
List: tech-net
Date: 10/26/2007 15:30:03
On Fri, Oct 26, 2007 at 06:33:17PM +0100, Iain Hibbert wrote:
> On Tue, 23 Oct 2007, Tom Spindler wrote:
>
> > Given that many of these pieces of sh^W^W^Wlovely source files
> > don't actually bother using 'struct queue', and far more often
> > monkey around with the affected structures themselves - it might
> > be better to just embed local copies of the routines into the
> > affected sources. (As the defs are all of five lines of code each,
> > I don't think it'd be a horrible burden.)
>
> Having looked at it in a bit more depth, I think that if no testers can be
> found for ISO/EON/TPIP then just hardcoding it is the cheapest option and
> is least likley to break anything not already broken, eg:
>
> --- /usr/src/sys/netiso/iso_pcb.c 2007-07-20 22:24:52.000000000 +0100
> +++ iso_pcb.c 2007-10-26 12:30:30.000000000 +0100
> @@ -118,7 +118,13 @@
> return ENOBUFS;
> isop->isop_head = head;
> isop->isop_socket = so;
> - insque(isop, head);
> +
> + /* insert at head of pcb list */
> + isop->isop_next = head->isop_next;
> + isop->isop_prev = head;
> + head->isop_next = isop;
> + isop->isop_next->isop_prev = isop;
> +
Please, don't do that. Use queue(3) macros. They work, developers
believe they work, and LIST_INSERT_HEAD() will reduce the lines of code
and comments in that example from five to one.
Dave
--
David Young OJC Technologies
dyoung@ojctech.com Urbana, IL * (217) 278-3933 ext 24