Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jan 2006 00:35:43 +0100
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Nate Lawson <nate@root.org>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/kern subr_bus.c 
Message-ID:  <33479.1137281743@critter.freebsd.dk>
In-Reply-To: Your message of "Sat, 14 Jan 2006 12:47:39 PST." <43C9636B.6070500@root.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <43C9636B.6070500@root.org>, Nate Lawson writes:
>Poul-Henning Kamp wrote:

>> Index: src/sys/kern/subr_bus.c
>> diff -u src/sys/kern/subr_bus.c:1.187 src/sys/kern/subr_bus.c:1.188
>> --- src/sys/kern/subr_bus.c:1.187	Tue Oct  4 22:25:14 2005
>> +++ src/sys/kern/subr_bus.c	Sat Jan 14 09:41:35 2006
>> @@ -2820,7 +2820,7 @@
>>  {
>>  	struct resource_list_entry *rle;
>>  
>> -	STAILQ_FOREACH(rle, rl, link) {
>> +	while ((rle = STAILQ_FIRST(rl)) != NULL) {
>>  		if (rle->res)
>>  			bus_release_resource(rman_get_device(rle->res),
>>  			    rle->type, rle->rid, rle->res);
>
>Isn't that what the STAILQ_FOREACH_SAFE() macro is for?  List traversal 
>with deletion?  Your approach is also fine.

In this case we empty the entire list, so this should be marginally
faster, which is probably irrelevevant, and maybe a tiny bit clearer
on the intent.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?33479.1137281743>