summaryrefslogtreecommitdiffstats
path: root/src/core/process.c
diff options
context:
space:
mode:
authorMichael Brown2010-11-08 03:51:18 +0100
committerMichael Brown2010-11-08 04:15:28 +0100
commitea631f6fb8dbffe3081ecf29eafa62ecd38ec64f (patch)
treef27d347fc48c524e172a4bdeea80976a26b9904a /src/core/process.c
parent[list] Extend list-manipulation assertions to all list-handling functions (diff)
downloadipxe-ea631f6fb8dbffe3081ecf29eafa62ecd38ec64f.tar.gz
ipxe-ea631f6fb8dbffe3081ecf29eafa62ecd38ec64f.tar.xz
ipxe-ea631f6fb8dbffe3081ecf29eafa62ecd38ec64f.zip
[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>
Diffstat (limited to 'src/core/process.c')
-rw-r--r--src/core/process.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/core/process.c b/src/core/process.c
index bc070e06..a3297856 100644
--- a/src/core/process.c
+++ b/src/core/process.c
@@ -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;
}
}