CLEANUP: lists/tree-wide: rename some list operations to avoid some confusion
The current "ADD" vs "ADDQ" is confusing because when thinking in terms
of appending at the end of a list, "ADD" naturally comes to mind, but
here it does the opposite, it inserts. Several times already it's been
incorrectly used where ADDQ was expected, the latest of which was a
fortunate accident explained in 6fa922562 ("CLEANUP: stream: explain
why we queue the stream at the head of the server list").
Let's use more explicit (but slightly longer) names now:
LIST_ADD -> LIST_INSERT
LIST_ADDQ -> LIST_APPEND
LIST_ADDED -> LIST_INLIST
LIST_DEL -> LIST_DELETE
The same is true for MT_LISTs, including their "TRY" variant.
LIST_DEL_INIT keeps its short name to encourage to use it instead of the
lazier LIST_DELETE which is often less safe.
The change is large (~674 non-comment entries) but is mechanical enough
to remain safe. No permutation was performed, so any out-of-tree code
can easily map older names to new ones.
The list doc was updated.
diff --git a/src/signal.c b/src/signal.c
index 946157e..5ec7142 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -154,7 +154,7 @@
if (sig != SIGPROF)
signal(sig, SIG_DFL);
list_for_each_entry_safe(sh, shb, &signal_state[sig].handlers, list) {
- LIST_DEL(&sh->list);
+ LIST_DELETE(&sh->list);
pool_free(pool_head_sig_handlers, sh);
}
}
@@ -188,7 +188,7 @@
sh->handler = fct;
sh->arg = arg;
sh->flags = SIG_F_TYPE_FCT;
- LIST_ADDQ(&signal_state[sig].handlers, &sh->list);
+ LIST_APPEND(&signal_state[sig].handlers, &sh->list);
return sh;
}
@@ -220,7 +220,7 @@
sh->handler = task;
sh->arg = reason & ~TASK_WOKEN_ANY;
sh->flags = SIG_F_TYPE_TASK;
- LIST_ADDQ(&signal_state[sig].handlers, &sh->list);
+ LIST_APPEND(&signal_state[sig].handlers, &sh->list);
return sh;
}
@@ -229,7 +229,7 @@
*/
void signal_unregister_handler(struct sig_handler *handler)
{
- LIST_DEL(&handler->list);
+ LIST_DELETE(&handler->list);
pool_free(pool_head_sig_handlers, handler);
}
@@ -251,7 +251,7 @@
list_for_each_entry_safe(sh, shb, &signal_state[sig].handlers, list) {
if (sh->handler == target) {
- LIST_DEL(&sh->list);
+ LIST_DELETE(&sh->list);
pool_free(pool_head_sig_handlers, sh);
break;
}
@@ -271,7 +271,7 @@
return;
list_for_each_entry_safe(sh, shb, &signal_state[sig].handlers, list) {
- LIST_DEL(&sh->list);
+ LIST_DELETE(&sh->list);
pool_free(pool_head_sig_handlers, sh);
}