From 36bd815ba77564398e1398ad7f071bafa34e93be Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 7 Sep 2023 12:05:29 +0200 Subject: [PATCH 1/2] Revert "lib: add a frr_each_const macro" This reverts commit 72eae2c3cb771b7010f3f07b6c638e9ae078bbdf. `frr_each_const(X, ...)` is not needed since it is the same as `frr_each(X_const, ...)`. The fact that it wasn't properly set up for clang-format, and that then work-arounded with "clang-format off" is all the more reason to not do this. Signed-off-by: David Lamparter --- isisd/isis_flex_algo.c | 5 +---- lib/typesafe.h | 3 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/isisd/isis_flex_algo.c b/isisd/isis_flex_algo.c index ef30987b8e..fbe249ab5a 100644 --- a/isisd/isis_flex_algo.c +++ b/isisd/isis_flex_algo.c @@ -127,10 +127,7 @@ _isis_flex_algo_elected(int algorithm, const struct isis_area *area, * Perform FAD comparison. First, compare the priority, and if they are * the same, compare the sys-id. */ - /* clang-format off */ - frr_each_const(lspdb, &area->lspdb[ISIS_LEVEL1 - 1], lsp) { - /* clang-format on */ - + frr_each (lspdb_const, &area->lspdb[ISIS_LEVEL1 - 1], lsp) { if (!lsp->tlvs || !lsp->tlvs->router_cap) continue; diff --git a/lib/typesafe.h b/lib/typesafe.h index 8eb59c33b7..d2587160ea 100644 --- a/lib/typesafe.h +++ b/lib/typesafe.h @@ -20,9 +20,6 @@ extern "C" { #define frr_each(prefix, head, item) \ for (item = prefix##_first(head); item; \ item = prefix##_next(head, item)) -#define frr_each_const(prefix, head, item) \ - for (item = prefix##_const_first(head); item; \ - item = prefix##_const_next(head, item)) #define frr_each_safe(prefix, head, item) \ for (typeof(prefix##_next_safe(head, NULL)) prefix##_safe = \ prefix##_next_safe(head, \ From 3ea3f34213f99990ff1108ed86393b35504df6e5 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Thu, 7 Sep 2023 17:11:52 +0200 Subject: [PATCH 2/2] lib: add inline comment about _const iteration This is noted in doc/developer/lists.rst, but judging by the previous commit that's not where people look for this thing. Let's try a comment in the header file. Signed-off-by: David Lamparter --- lib/typesafe.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/typesafe.h b/lib/typesafe.h index d2587160ea..a84298b062 100644 --- a/lib/typesafe.h +++ b/lib/typesafe.h @@ -17,6 +17,11 @@ extern "C" { /* generic macros for all list-like types */ +/* to iterate using the const variants of the functions, append "_const" to + * the name of the container, e.g. "frr_each (my_list, head, item)" becomes + * "frr_each (my_list_const, head, item)" + */ + #define frr_each(prefix, head, item) \ for (item = prefix##_first(head); item; \ item = prefix##_next(head, item))