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.
This commit is contained in:
Willy Tarreau
2021-04-21 07:32:39 +02:00
parent 3b9cdf1cb7
commit 2b71810cb3
83 changed files with 830 additions and 929 deletions

View File

@@ -312,7 +312,7 @@ static inline struct hlua_function *new_hlua_function()
fcn = calloc(1, sizeof(*fcn));
if (!fcn)
return NULL;
LIST_ADDQ(&referenced_functions, &fcn->l);
LIST_APPEND(&referenced_functions, &fcn->l);
for (i = 0; i < MAX_THREADS + 1; i++)
fcn->function_ref[i] = -1;
return fcn;
@@ -324,7 +324,7 @@ static inline void release_hlua_function(struct hlua_function *fcn)
return;
if (fcn->name)
ha_free(&fcn->name);
LIST_DEL(&fcn->l);
LIST_DELETE(&fcn->l);
ha_free(&fcn);
}
@@ -6387,7 +6387,7 @@ __LJMP static int hlua_register_init(lua_State *L)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
init->function_ref = ref;
LIST_ADDQ(&hlua_init_functions[hlua_state_id], &init->l);
LIST_APPEND(&hlua_init_functions[hlua_state_id], &init->l);
return 0;
}
@@ -8499,7 +8499,7 @@ static int hlua_config_prepend_path(char **args, int section_type, struct proxy
memprintf(err, "memory allocation failed");
goto err2;
}
LIST_ADDQ(&prepend_path_list, &p->l);
LIST_APPEND(&prepend_path_list, &p->l);
hlua_prepend_path(hlua_states[0], type, path);
hlua_prepend_path(hlua_states[1], type, path);