]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: rename new ForEach macros from the typesafe API
authorRenato Westphal <renato@opensourcerouting.org>
Mon, 20 May 2019 21:52:16 +0000 (18:52 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 21 May 2019 18:59:08 +0000 (15:59 -0300)
This is necessary to avoid a name collision with std::for_each
from C++.

Fixes the compilation of the gRPC northbound module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
isisd/isis_circuit.c
isisd/isis_lsp.c
isisd/isis_pdu.c
isisd/isis_tlvs.c
isisd/isis_vty_fabricd.c
lib/thread.c
lib/typesafe.h
tests/lib/test_atomlist.c
tests/lib/test_typelist.h
zebra/zebra_rib.c

index f9a0285872f652719ececbac422df9b3fe4f89bf..8d008d78bd4800d2e3618f1b3d66149d117e4f71 100644 (file)
@@ -551,7 +551,7 @@ static void isis_circuit_update_all_srmflags(struct isis_circuit *circuit,
                if (!lspdb_count(&area->lspdb[level - 1]))
                        continue;
 
-               for_each (lspdb, &area->lspdb[level - 1], lsp) {
+               frr_each (lspdb, &area->lspdb[level - 1], lsp) {
                        if (is_set) {
                                isis_tx_queue_add(circuit->tx_queue, lsp,
                                                  TX_LSP_NORMAL);
index 1991666954b96f34f2641812e6920ee6d3ee8002..4b29e6dc7e0d7baee8faf159d5b7870b0741ebd3 100644 (file)
@@ -574,7 +574,7 @@ void lsp_build_list_nonzero_ht(struct lspdb_head *head, const uint8_t *start_id,
        memcpy(&searchfor.hdr.lsp_id, start_id, sizeof(searchfor.hdr.lsp_id));
 
        start = lspdb_find_gteq(head, &searchfor);
-       for_each_from (lspdb, head, lsp, start) {
+       frr_each_from (lspdb, head, lsp, start) {
                if (memcmp(lsp->hdr.lsp_id, stop_id,
                           ISIS_SYS_ID_LEN + 2) > 0)
                        break;
@@ -682,12 +682,12 @@ int lsp_print_all(struct vty *vty, struct lspdb_head *head, char detail,
        int lsp_count = 0;
 
        if (detail == ISIS_UI_LEVEL_BRIEF) {
-               for_each (lspdb, head, lsp) {
+               frr_each (lspdb, head, lsp) {
                        lsp_print(lsp, vty, dynhost);
                        lsp_count++;
                }
        } else if (detail == ISIS_UI_LEVEL_DETAIL) {
-               for_each (lspdb, head, lsp) {
+               frr_each (lspdb, head, lsp) {
                        lsp_print_detail(lsp, vty, dynhost);
                        lsp_count++;
                }
@@ -1855,7 +1855,7 @@ int lsp_tick(struct thread *thread)
         */
        for (level = 0; level < ISIS_LEVELS; level++) {
                struct isis_lsp *next = lspdb_first(&area->lspdb[level]);
-               for_each_from (lspdb, &area->lspdb[level], lsp, next) {
+               frr_each_from (lspdb, &area->lspdb[level], lsp, next) {
                        /*
                         * The lsp rem_lifetime is kept at 0 for MaxAge
                         * or
index 9c633117b0f86a308cc493cb6667cf65484995c0..3d16d56016568ce53d40feb90aa676dec9a6bcf6 100644 (file)
@@ -2258,7 +2258,7 @@ static int send_psnp(int level, struct isis_circuit *circuit)
                if (CHECK_FLAG(passwd->snp_auth, SNP_AUTH_SEND))
                        isis_tlvs_add_auth(tlvs, passwd);
 
-               for_each (lspdb, &circuit->area->lspdb[level - 1], lsp) {
+               frr_each (lspdb, &circuit->area->lspdb[level - 1], lsp) {
                        if (ISIS_CHECK_FLAG(lsp->SSNflags, circuit))
                                isis_tlvs_add_lsp_entry(tlvs, lsp);
 
index ae149a04284cd0cb6b8440fa13d49c82c5d17fd1..6b8e74f07ba872025760ca7739980bb04fb724db 100644 (file)
@@ -3552,7 +3552,7 @@ void isis_tlvs_add_csnp_entries(struct isis_tlvs *tlvs, uint8_t *start_id,
        if (!first)
                return;
 
-       for_each_from (lspdb, head, lsp, first) {
+       frr_each_from (lspdb, head, lsp, first) {
                if (memcmp(lsp->hdr.lsp_id, stop_id, sizeof(lsp->hdr.lsp_id))
                        > 0 || tlvs->lsp_entries.count == num_lsps)
                        break;
index 7f2061692f5be390b208b4949313ab4f8349eb0e..2476bd2552b84d98c127b529972bf427d197ee0d 100644 (file)
@@ -176,7 +176,7 @@ DEFUN (show_lsp_flooding,
                        continue;
                }
 
-               for_each (lspdb, head, lsp) {
+               frr_each (lspdb, head, lsp) {
                        lsp_print_flooding(vty, lsp);
                        vty_out(vty, "\n");
                }
index 9489e3e923f31ed54a65639a4b3a6fa33908edef..7a9a0ab608e6ff8cd57d22456274d6fe57b360ef 100644 (file)
@@ -1034,7 +1034,7 @@ static void do_thread_cancel(struct thread_master *master)
                if (cr->eventobj) {
                        struct thread *t;
 
-                       for_each_safe(thread_list, &master->event, t) {
+                       frr_each_safe(thread_list, &master->event, t) {
                                if (t->arg != cr->eventobj)
                                        continue;
                                thread_list_del(&master->event, t);
@@ -1043,7 +1043,7 @@ static void do_thread_cancel(struct thread_master *master)
                                thread_add_unuse(master, t);
                        }
 
-                       for_each_safe(thread_list, &master->ready, t) {
+                       frr_each_safe(thread_list, &master->ready, t) {
                                if (t->arg != cr->eventobj)
                                        continue;
                                thread_list_del(&master->ready, t);
index 6829b0a388c2257ae3eb158d330299266d28d669..0a4ed69e4eb6738331a7a08a1eba086204fcdfdd 100644 (file)
@@ -29,17 +29,17 @@ extern "C" {
 
 /* generic macros for all list-like types */
 
-#define for_each(prefix, head, item)                                           \
+#define frr_each(prefix, head, item)                                           \
        for (item = prefix##_first(head); item;                                \
                        item = prefix##_next(head, item))
-#define for_each_safe(prefix, head, item)                                      \
+#define frr_each_safe(prefix, head, item)                                      \
        for (typeof(prefix##_next_safe(head, NULL)) prefix##_safe =            \
                        prefix##_next_safe(head,                               \
                                (item = prefix##_first(head)));                \
                item;                                                          \
                item = prefix##_safe,                                          \
                        prefix##_safe = prefix##_next_safe(head, prefix##_safe))
-#define for_each_from(prefix, head, item, from)                                \
+#define frr_each_from(prefix, head, item, from)                                \
        for (item = from, from = prefix##_next_safe(head, item);               \
                item;                                                          \
                item = from, from = prefix##_next_safe(head, from))
index 078e05e3365db1b587566a4c50a9a4777c6c8946..249fff8edb34e2659283e80954e8036886b66133 100644 (file)
@@ -308,7 +308,7 @@ static void run_tr(struct testrun *tr)
        if (tr->sorted) {
                uint64_t prevval = 0;
 
-               for_each(asort, &shead, item) {
+               frr_each(asort, &shead, item) {
                        assert(item->val1 >= prevval);
                        prevval = item->val1;
                        c++;
@@ -316,7 +316,7 @@ static void run_tr(struct testrun *tr)
                assert(c == asort_count(&shead));
        } else {
                prev = &dummy;
-               for_each(alist, &ahead, item) {
+               frr_each(alist, &ahead, item) {
                        assert(item != prev);
                        prev = item;
                        c++;
@@ -335,7 +335,7 @@ static void dump(const char *lbl)
        size_t ctr = 0;
 
        printf("dumping %s:\n", lbl);
-       for_each_safe(alist, &ahead, item) {
+       frr_each_safe(alist, &ahead, item) {
                printf("%s %3zu %p %3"PRIu64" %3"PRIu64"\n", lbl, ctr++,
                                (void *)item, item->val1, item->val2);
        }
index f09175fea5c982b6ffd71d7a9a9e69fddeea788b..b288f0bd8e33c578765325cc89c1933f47d41c55 100644 (file)
@@ -105,7 +105,7 @@ static void ts_hash(const char *text, const char *expect)
        SHA256_Init(&ctx);
        SHA256_Update(&ctx, &count, sizeof(count));
 
-       for_each (list, &head, item) {
+       frr_each (list, &head, item) {
                struct {
                        uint32_t val_upper, val_lower, index;
                } hashitem = {
@@ -177,7 +177,7 @@ static void concat(test_, TYPE)(void)
 
        k = 0;
        prev = NULL;
-       for_each(list, &head, item) {
+       frr_each(list, &head, item) {
 #if IS_HASH(REALTYPE) || IS_HEAP(REALTYPE)
                /* hash table doesn't give sorting */
                (void)prev;
@@ -303,7 +303,7 @@ static void concat(test_, TYPE)(void)
        assert(l + list_count(&head) == k);
        ts_hashx("del", "cb2e5d80f08a803ef7b56c15e981b681adcea214bebc2f55e12e0bfb242b07ca");
 
-       for_each_safe(list, &head, item) {
+       frr_each_safe(list, &head, item) {
                assert(item->scratchpad != 0);
 
                if (item->val & 1) {
@@ -313,7 +313,7 @@ static void concat(test_, TYPE)(void)
                }
        }
        assert(l + list_count(&head) == k);
-       ts_hashx("for_each_safe+del", "e0beb71dd963a75af05b722b8e71b61b304587d860c8accdc4349067542b86bb");
+       ts_hashx("frr_each_safe+del", "e0beb71dd963a75af05b722b8e71b61b304587d860c8accdc4349067542b86bb");
 
 #else /* !IS_SORTED */
        prng = prng_new(0);
index 3b305f6e3d853efcd54272ba6775162ed62fb85c..8f27316669af3724ecf50badec7ca217681ffed3 100644 (file)
@@ -1229,7 +1229,7 @@ void zebra_rib_evaluate_rn_nexthops(struct route_node *rn, uint32_t seq)
                 * nht resolution and as such we need to call the
                 * nexthop tracking evaluation code
                 */
-               for_each (rnh_list, &dest->nht, rnh) {
+               frr_each (rnh_list, &dest->nht, rnh) {
                        struct zebra_vrf *zvrf =
                                zebra_vrf_lookup_by_id(rnh->vrf_id);
                        struct prefix *p = &rnh->node->p;
@@ -3223,7 +3223,7 @@ unsigned long rib_score_proto(uint8_t proto, unsigned short instance)
                               proto, instance,
                               zvrf->table[AFI_IP6][SAFI_UNICAST]);
 
-               for_each(otable, &zvrf->other_tables, ort) cnt +=
+               frr_each(otable, &zvrf->other_tables, ort) cnt +=
                        rib_score_proto_table(proto, instance, ort->table);
        }