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/addons/51degrees/51d.c b/addons/51degrees/51d.c
index 2c52c59..6dfa578 100644
--- a/addons/51degrees/51d.c
+++ b/addons/51degrees/51d.c
@@ -91,7 +91,7 @@
while (*(args[cur_arg])) {
name = calloc(1, sizeof(*name));
name->name = strdup(args[cur_arg]);
- LIST_ADDQ(&global_51degrees.property_names, &name->list);
+ LIST_APPEND(&global_51degrees.property_names, &name->list);
++cur_arg;
}
@@ -730,7 +730,7 @@
ha_free(&global_51degrees.data_file_path);
list_for_each_entry_safe(_51d_prop_name, _51d_prop_nameb, &global_51degrees.property_names, list) {
- LIST_DEL(&_51d_prop_name->list);
+ LIST_DELETE(&_51d_prop_name->list);
free(_51d_prop_name);
}
diff --git a/addons/ot/include/define.h b/addons/ot/include/define.h
index 8769161..d34f6b9 100644
--- a/addons/ot/include/define.h
+++ b/addons/ot/include/define.h
@@ -53,7 +53,7 @@
#define FLT_OT_RUN_ONCE(f) do { static bool __f = 1; if (__f) { __f = 0; f; } } while (0)
#define FLT_OT_LIST_ISVALID(a) (((a) != NULL) && ((a)->n != NULL) && ((a)->p != NULL))
-#define FLT_OT_LIST_DEL(a) do { if (FLT_OT_LIST_ISVALID(a)) LIST_DEL(a); } while (0)
+#define FLT_OT_LIST_DEL(a) do { if (FLT_OT_LIST_ISVALID(a)) LIST_DELETE(a); } while (0)
#define FLT_OT_LIST_DESTROY(t,h) \
do { \
struct flt_ot_conf_##t *_ptr, *_back; \
diff --git a/addons/ot/src/conf.c b/addons/ot/src/conf.c
index 626d418..71db967 100644
--- a/addons/ot/src/conf.c
+++ b/addons/ot/src/conf.c
@@ -67,7 +67,7 @@
retptr->cfg_line = linenum;
if (head != NULL)
- LIST_ADDQ(head, &(retptr->list));
+ LIST_APPEND(head, &(retptr->list));
} else {
FLT_OT_ERR("out of memory");
}
@@ -680,7 +680,7 @@
}
FLT_OT_DBG(2, "- deleting proxy_log.logsrvs list %s", flt_ot_list_debug(&((*ptr)->proxy_log.logsrvs)));
list_for_each_entry_safe(logsrv, logsrvback, &((*ptr)->proxy_log.logsrvs), list) {
- LIST_DEL(&(logsrv->list));
+ LIST_DELETE(&(logsrv->list));
FLT_OT_FREE(logsrv);
}
FLT_OT_LIST_DESTROY(ph_group, &((*ptr)->ph_groups));
diff --git a/addons/ot/src/scope.c b/addons/ot/src/scope.c
index ace8a22..8305f24 100644
--- a/addons/ot/src/scope.c
+++ b/addons/ot/src/scope.c
@@ -256,7 +256,7 @@
retptr->ref_type = ref_type;
retptr->ref_span = ref_span;
retptr->ref_ctx = ref_ctx;
- LIST_ADD(&(rt_ctx->spans), &(retptr->list));
+ LIST_INSERT(&(rt_ctx->spans), &(retptr->list));
FLT_OT_DBG_SCOPE_SPAN("new span ", retptr);
@@ -352,7 +352,7 @@
retptr->id_len = id_len;
retptr->smp_opt_dir = dir;
retptr->context = span_ctx;
- LIST_ADD(&(rt_ctx->contexts), &(retptr->list));
+ LIST_INSERT(&(rt_ctx->contexts), &(retptr->list));
FLT_OT_DBG_SCOPE_CONTEXT("new context ", retptr);
diff --git a/addons/wurfl/wurfl.c b/addons/wurfl/wurfl.c
index 8ec1783..e9780e4 100644
--- a/addons/wurfl/wurfl.c
+++ b/addons/wurfl/wurfl.c
@@ -204,7 +204,7 @@
wi->data.name = strdup(args[argIdx]);
wi->data.type = HA_WURFL_DATA_TYPE_UNKNOWN;
wi->data.func_callback = NULL;
- LIST_ADDQ(&global_wurfl.information_list, &wi->list);
+ LIST_APPEND(&global_wurfl.information_list, &wi->list);
++argIdx;
}
@@ -232,7 +232,7 @@
}
wp->patch_file_path = strdup(args[argIdx]);
- LIST_ADDQ(&global_wurfl.patch_file_list, &wp->list);
+ LIST_APPEND(&global_wurfl.patch_file_list, &wp->list);
++argIdx;
}
@@ -410,12 +410,12 @@
ha_free(&global_wurfl.cache_size);
list_for_each_entry_safe(wi, wi2, &global_wurfl.information_list, list) {
- LIST_DEL(&wi->list);
+ LIST_DELETE(&wi->list);
free(wi);
}
list_for_each_entry_safe(wp, wp2, &global_wurfl.patch_file_list, list) {
- LIST_DEL(&wp->list);
+ LIST_DELETE(&wp->list);
free(wp);
}