fib: Expressive type for walk return code. Honour code. 48/30148/2
authorNeale Ranns <neale.ranns@cisco.com>
Thu, 26 Nov 2020 09:34:39 +0000 (09:34 +0000)
committerBeno�t Ganne <bganne@cisco.com>
Thu, 26 Nov 2020 13:18:29 +0000 (13:18 +0000)
Type: improvement

Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Change-Id: I487e698555545fce85d02d55deaaf7bb0007e388

src/vnet/dpo/load_balance_map.c
src/vnet/fib/fib_attached_export.c
src/vnet/fib/fib_entry_cover.c
src/vnet/fib/fib_entry_cover.h
src/vnet/fib/fib_node.c
src/vnet/fib/fib_node_list.c
src/vnet/fib/fib_node_list.h
src/vnet/mfib/mfib_entry_cover.c

index c03acaf..de5f30b 100644 (file)
@@ -491,7 +491,7 @@ load_balance_map_unlock (index_t lbmi)
     }
 }
 
-static int
+static walk_rc_t
 load_balance_map_path_state_change_walk (fib_node_ptr_t *fptr,
                                          void *ctx)
 {
@@ -501,7 +501,7 @@ load_balance_map_path_state_change_walk (fib_node_ptr_t *fptr,
 
     load_balance_map_fill(lbm);
 
-    return (!0);
+    return (WALK_CONTINUE);
 }
 
 /**
index 4a33b88..5ea96fd 100644 (file)
@@ -205,7 +205,7 @@ fib_entry_import_add (fib_ae_import_t *import,
 /**
  * Call back when walking a connected prefix's covered prefixes for import
  */
-static int
+static walk_rc_t
 fib_entry_covered_walk_import (fib_entry_t *cover,
                               fib_node_index_t covered,
                               void *ctx)
@@ -214,7 +214,7 @@ fib_entry_covered_walk_import (fib_entry_t *cover,
 
     fib_entry_import_add(import, covered);
 
-    return (0);
+    return (WALK_CONTINUE);
 }
 
 /*
index 153bd70..47bc5c3 100644 (file)
@@ -72,7 +72,7 @@ typedef struct fib_enty_cover_walk_ctx_t_ {
     void *ctx;
 } fib_enty_cover_walk_ctx_t;
 
-static int
+static walk_rc_t
 fib_entry_cover_walk_node_ptr (fib_node_ptr_t *depend,
                               void *args)
 {
@@ -80,8 +80,7 @@ fib_entry_cover_walk_node_ptr (fib_node_ptr_t *depend,
 
     ctx->walk(ctx->cover, depend->fnp_index, ctx->ctx);
 
-    /* continue */
-    return (1);
+    return (WALK_CONTINUE);
 }
 
 void
@@ -107,7 +106,7 @@ fib_entry_cover_walk (fib_entry_t *cover,
                        &ctx);
 }
 
-static int
+static walk_rc_t
 fib_entry_cover_change_one (fib_entry_t *cover,
                            fib_node_index_t covered,
                            void *args)
@@ -144,8 +143,7 @@ fib_entry_cover_change_one (fib_entry_t *cover,
            fib_entry_cover_changed(covered);
        }
     }
-    /* continue */
-    return (1);
+    return (WALK_CONTINUE);
 }
 
 void
@@ -161,15 +159,14 @@ fib_entry_cover_change_notify (fib_node_index_t cover_index,
                         uword_to_pointer(covered, void*));
 }
 
-static int
+static walk_rc_t
 fib_entry_cover_update_one (fib_entry_t *cover,
                            fib_node_index_t covered,
                            void *args)
 {
     fib_entry_cover_updated(covered);
 
-    /* continue */
-    return (1);
+    return (WALK_CONTINUE);
 }
 
 void
index 500d5b3..499efdc 100644 (file)
@@ -21,9 +21,9 @@
 /**
  * callback function used when walking the covered entries
  */
-typedef int (*fib_entry_covered_walk_t)(fib_entry_t *cover,
-                                       fib_node_index_t covered,
-                                       void *ctx);
+typedef walk_rc_t (*fib_entry_covered_walk_t)(fib_entry_t *cover,
+                                              fib_node_index_t covered,
+                                              void *ctx);
 
 extern u32 fib_entry_cover_track(fib_entry_t *cover,
                                 fib_node_index_t covered);
index 3e99007..1d3abd5 100644 (file)
@@ -161,7 +161,7 @@ fib_node_back_walk_one (fib_node_ptr_t *ptr,
     return (fn_vfts[ptr->fnp_type].fnv_back_walk(node, ctx));
 }
 
-static int
+static walk_rc_t
 fib_node_ptr_format_one_child (fib_node_ptr_t *ptr,
                               void *arg)
 {
@@ -169,7 +169,7 @@ fib_node_ptr_format_one_child (fib_node_ptr_t *ptr,
 
     *s = fib_node_format(ptr, *s);
 
-    return (1);
+    return (WALK_CONTINUE);
 }
 
 u8*
index ceb951b..bcd9a09 100644 (file)
@@ -372,7 +372,8 @@ fib_node_list_walk (fib_node_list_t list,
         elt = fib_node_list_elt_get(sibling);
         sibling = elt->fnle_next;
 
-        fn(&elt->fnle_owner, args);
+        if (WALK_STOP == fn(&elt->fnle_owner, args))
+            break;
     }
 }
 
index 9567b96..76abec5 100644 (file)
@@ -52,8 +52,8 @@ extern u32 fib_node_list_get_size(fib_node_list_t head);
 /**
  * @brief Callback function invoked during a list walk
  */
-typedef int (*fib_node_list_walk_cb_t)(fib_node_ptr_t *owner,
-                                       void *args);
+typedef walk_rc_t (*fib_node_list_walk_cb_t)(fib_node_ptr_t *owner,
+                                             void *args);
 
 extern void fib_node_list_walk(fib_node_list_t head,
                                fib_node_list_walk_cb_t fn,
index 6caeb1b..2f5fd6b 100644 (file)
@@ -71,7 +71,7 @@ typedef struct mfib_enty_cover_walk_ctx_t_ {
     void *ctx;
 } mfib_enty_cover_walk_ctx_t;
 
-static int
+static walk_rc_t
 mfib_entry_cover_walk_node_ptr (fib_node_ptr_t *depend,
                                 void *args)
 {
@@ -79,8 +79,7 @@ mfib_entry_cover_walk_node_ptr (fib_node_ptr_t *depend,
 
     ctx->walk(ctx->cover, depend->fnp_index, ctx->ctx);
 
-    /* continue */
-    return (1);
+    return (WALK_CONTINUE);
 }
 
 void