mirror of
https://github.com/ipxe/ipxe
synced 2025-12-22 21:11:03 +03:00
[list] Add list_first_entry()
There are several points in the iPXE codebase where list_for_each_entry() is (ab)used to extract only the first entry from a list. Add a macro list_first_entry() to make this code easier to read. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -83,7 +83,8 @@ void process_del ( struct process *process ) {
|
||||
void step ( void ) {
|
||||
struct process *process;
|
||||
|
||||
list_for_each_entry ( process, &run_queue, list ) {
|
||||
if ( ( process = list_first_entry ( &run_queue, struct process,
|
||||
list ) ) ) {
|
||||
list_del ( &process->list );
|
||||
list_add_tail ( &process->list, &run_queue );
|
||||
ref_get ( process->refcnt ); /* Inhibit destruction mid-step */
|
||||
@@ -93,7 +94,6 @@ void step ( void ) {
|
||||
DBGC2 ( process, "PROCESS %p (%p) finished executing\n",
|
||||
process, process->step );
|
||||
ref_put ( process->refcnt ); /* Allow destruction */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user