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/http_htx.c b/src/http_htx.c
index 2ddc50e..c3422d4 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -1009,9 +1009,9 @@
ha_free(&http_reply->ctype);
list_for_each_entry_safe(hdr, hdrb, &http_reply->hdrs, list) {
- LIST_DEL(&hdr->list);
+ LIST_DELETE(&hdr->list);
list_for_each_entry_safe(lf, lfb, &hdr->value, list) {
- LIST_DEL(&lf->list);
+ LIST_DELETE(&lf->list);
release_sample_expr(lf->expr);
free(lf->arg);
free(lf);
@@ -1027,7 +1027,7 @@
chunk_destroy(&http_reply->body.obj);
else if (http_reply->type == HTTP_REPLY_LOGFMT) {
list_for_each_entry_safe(lf, lfb, &http_reply->body.fmt, list) {
- LIST_DEL(&lf->list);
+ LIST_DELETE(&lf->list);
release_sample_expr(lf->expr);
free(lf->arg);
free(lf);
@@ -1100,12 +1100,12 @@
free(http_errs->id);
for (rc = 0; rc < HTTP_ERR_SIZE; rc++)
release_http_reply(http_errs->replies[rc]);
- LIST_DEL(&http_errs->list);
+ LIST_DELETE(&http_errs->list);
free(http_errs);
}
list_for_each_entry_safe(http_rep, http_repb, &http_replies_list, list) {
- LIST_DEL(&http_rep->list);
+ LIST_DELETE(&http_rep->list);
release_http_reply(http_rep);
}
}
@@ -1598,7 +1598,7 @@
memprintf(errmsg, "'%s' : out of memory", args[cur_arg-1]);
goto error;
}
- LIST_ADDQ(&reply->hdrs, &hdr->list);
+ LIST_APPEND(&reply->hdrs, &hdr->list);
LIST_INIT(&hdr->value);
hdr->name = ist(strdup(args[cur_arg]));
if (!isttest(hdr->name)) {
@@ -1654,9 +1654,9 @@
"with an erorrfile.\n",
px->conf.args.file, px->conf.args.line);
list_for_each_entry_safe(hdr, hdrb, &reply->hdrs, list) {
- LIST_DEL(&hdr->list);
+ LIST_DELETE(&hdr->list);
list_for_each_entry_safe(lf, lfb, &hdr->value, list) {
- LIST_DEL(&lf->list);
+ LIST_DELETE(&lf->list);
release_sample_expr(lf->expr);
free(lf->arg);
free(lf);
@@ -1759,7 +1759,7 @@
reply->ctype = NULL;
LIST_INIT(&reply->hdrs);
reply->body.errmsg = msg;
- LIST_ADDQ(&http_replies_list, &reply->list);
+ LIST_APPEND(&http_replies_list, &reply->list);
conf_err = calloc(1, sizeof(*conf_err));
if (!conf_err) {
@@ -1774,7 +1774,7 @@
conf_err->file = strdup(file);
conf_err->line = line;
- LIST_ADDQ(&curpx->conf.errors, &conf_err->list);
+ LIST_APPEND(&curpx->conf.errors, &conf_err->list);
/* handle warning message */
if (*errmsg)
@@ -1825,7 +1825,7 @@
reply->ctype = NULL;
LIST_INIT(&reply->hdrs);
reply->body.errmsg = msg;
- LIST_ADDQ(&http_replies_list, &reply->list);
+ LIST_APPEND(&http_replies_list, &reply->list);
conf_err = calloc(1, sizeof(*conf_err));
if (!conf_err) {
@@ -1839,7 +1839,7 @@
conf_err->info.errorfile.reply = reply;
conf_err->file = strdup(file);
conf_err->line = line;
- LIST_ADDQ(&curpx->conf.errors, &conf_err->list);
+ LIST_APPEND(&curpx->conf.errors, &conf_err->list);
/* handle warning message */
if (*errmsg)
@@ -1901,7 +1901,7 @@
}
conf_err->file = strdup(file);
conf_err->line = line;
- LIST_ADDQ(&curpx->conf.errors, &conf_err->list);
+ LIST_APPEND(&curpx->conf.errors, &conf_err->list);
out:
return ret;
@@ -1970,11 +1970,11 @@
conf_err->type = 1;
conf_err->info.errorfile.status = reply->status;
conf_err->info.errorfile.reply = reply;
- LIST_ADDQ(&http_replies_list, &reply->list);
+ LIST_APPEND(&http_replies_list, &reply->list);
}
conf_err->file = strdup(file);
conf_err->line = line;
- LIST_ADDQ(&curpx->conf.errors, &conf_err->list);
+ LIST_APPEND(&curpx->conf.errors, &conf_err->list);
/* handle warning message */
if (*errmsg)
@@ -2036,7 +2036,7 @@
}
}
next:
- LIST_DEL(&conf_err->list);
+ LIST_DELETE(&conf_err->list);
free(conf_err->file);
free(conf_err);
}
@@ -2099,7 +2099,7 @@
}
new_conf_err->file = strdup(conf_err->file);
new_conf_err->line = conf_err->line;
- LIST_ADDQ(&curpx->conf.errors, &new_conf_err->list);
+ LIST_APPEND(&curpx->conf.errors, &new_conf_err->list);
new_conf_err = NULL;
}
ret = 1;
@@ -2116,7 +2116,7 @@
list_for_each_entry_safe(conf_err, conf_err_back, &px->conf.errors, list) {
if (conf_err->type == 0)
free(conf_err->info.errorfiles.name);
- LIST_DEL(&conf_err->list);
+ LIST_DELETE(&conf_err->list);
free(conf_err->file);
free(conf_err);
}
@@ -2168,7 +2168,7 @@
goto out;
}
- LIST_ADDQ(&http_errors_list, &curr_errs->list);
+ LIST_APPEND(&http_errors_list, &curr_errs->list);
curr_errs->id = strdup(args[1]);
curr_errs->conf.file = strdup(file);
curr_errs->conf.line = linenum;