cvs commit: src/sys/kern subr_bus.c

Poul-Henning Kamp phk at phk.freebsd.dk
Sat Jan 14 15:35:46 PST 2006


In message <43C9636B.6070500 at 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 at 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.


More information about the cvs-src mailing list