vppinfra: Improve code portability
[vpp.git] / src / plugins / cdp / cdp_input.c
index a27113d..914d4de 100644 (file)
@@ -167,25 +167,24 @@ _(version,DEBUG_TLV_DUMP)                       \
 _(platform,DEBUG_TLV_DUMP)                      \
 _(port_id,DEBUG_TLV_DUMP)
 
-#define _(z,dbg)                                                        \
-static                                                                  \
-cdp_error_t process_##z##_tlv (cdp_main_t *cm, cdp_neighbor_t *n,       \
-                                  cdp_tlv_t *t)                         \
-{                                                                       \
-    int i;                                                              \
-    if (dbg)                                                            \
-       fformat(stdout, "%U\n", format_text_tlv, t);                     \
-                                                                        \
-    if (n->z)                                                           \
-        _vec_len(n->z) = 0;                                             \
-                                                                        \
-    for (i = 0; i < (t->l - sizeof (*t)); i++)                          \
-        vec_add1(n->z, t->v[i]);                                        \
-                                                                        \
-    vec_add1(n->z, 0);                                                  \
-                                                                        \
-    return CDP_ERROR_NONE;                                              \
-}
+#define _(z, dbg)                                                             \
+  static cdp_error_t process_##z##_tlv (cdp_main_t *cm, cdp_neighbor_t *n,    \
+                                       cdp_tlv_t *t)                         \
+  {                                                                           \
+    int i;                                                                    \
+    if (dbg)                                                                  \
+      fformat (stdout, "%U\n", format_text_tlv, t);                           \
+                                                                              \
+    if (n->z)                                                                 \
+      vec_set_len (n->z, 0);                                                  \
+                                                                              \
+    for (i = 0; i < (t->l - sizeof (*t)); i++)                                \
+      vec_add1 (n->z, t->v[i]);                                               \
+                                                                              \
+    vec_add1 (n->z, 0);                                                       \
+                                                                              \
+    return CDP_ERROR_NONE;                                                    \
+  }
 
 foreach_text_to_struct_tlv
 #undef _
@@ -354,7 +353,7 @@ cdp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
    */
 
   if (n->last_rx_pkt)
-    _vec_len (n->last_rx_pkt) = 0;
+    vec_set_len (n->last_rx_pkt, 0);
 
   /* cdp disabled on this interface, we're done */
   if (n->disabled)
@@ -408,14 +407,7 @@ cdp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
 static clib_error_t *
 cdp_input_init (vlib_main_t * vm)
 {
-  clib_error_t *error;
   cdp_main_t *cm = &cdp_main;
-  void vnet_cdp_node_reference (void);
-
-  vnet_cdp_node_reference ();
-
-  if ((error = vlib_call_init_function (vm, cdp_periodic_init)))
-    return error;
 
   cm->vlib_main = vm;
   cm->vnet_main = vnet_get_main ();
@@ -424,7 +416,10 @@ cdp_input_init (vlib_main_t * vm)
   return 0;
 }
 
-VLIB_INIT_FUNCTION (cdp_input_init);
+VLIB_INIT_FUNCTION (cdp_input_init) =
+{
+  .runs_after = VLIB_INITS("cdp_periodic_init"),
+};
 
 
 static u8 *
@@ -437,20 +432,18 @@ format_cdp_neighbors (u8 * s, va_list * va)
   vnet_hw_interface_t *hw;
 
   s = format (s,
-             "%=25s %=15s %=25s %=10s\n",
+             "%=25s %=25s %=25s %=10s\n",
              "Our Port", "Peer System", "Peer Port", "Last Heard");
 
-  /* *INDENT-OFF* */
-  pool_foreach (n, cm->neighbors,
-  ({
+  pool_foreach (n, cm->neighbors)
+   {
     hw = vnet_get_sup_hw_interface (vnm, n->sw_if_index);
 
     if (n->disabled == 0)
-      s = format (s, "%=25s %=15s %=25s %=10.1f\n",
+      s = format (s, "%=25v %=25s %=25s %=10.1f\n",
                   hw->name, n->device_name, n->port_id,
                   n->last_heard);
-  }));
-  /* *INDENT-ON* */
+  }
   return s;
 }
 
@@ -468,13 +461,11 @@ show_cdp (vlib_main_t * vm,
   return 0;
 }
 
-/* *INDENT-OFF* */
 VLIB_CLI_COMMAND (show_cdp_command, static) = {
   .path = "show cdp",
   .short_help = "Show cdp command",
   .function = show_cdp,
 };
-/* *INDENT-ON* */
 
 
 /*