diff options
author | Damjan Marion <damarion@cisco.com> | 2022-05-20 16:01:22 +0200 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2022-09-26 08:14:29 +0000 |
commit | fe45f8f5afbf34d68cf992cc32b12432a82cdb38 (patch) | |
tree | ae8126e78d184022ef97007e64ac1f3350537a40 /src/vlibmemory/memory_api.c | |
parent | b70497124840fb6d9e8e5cf7239a41cb2bc7013c (diff) |
api: replace print functions wth format
Type: improvement
Change-Id: I7f7050c19453a69a7fb6c5e62f8f57db847d9144
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlibmemory/memory_api.c')
-rw-r--r-- | src/vlibmemory/memory_api.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/src/vlibmemory/memory_api.c b/src/vlibmemory/memory_api.c index 80d8628bf56..01fe49bfe31 100644 --- a/src/vlibmemory/memory_api.c +++ b/src/vlibmemory/memory_api.c @@ -28,7 +28,6 @@ #undef vl_typedefs /* instantiate all the print functions we know about */ -#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) #define vl_printfun #include <vlibmemory/vl_memory_api_h.h> #undef vl_printfun @@ -504,18 +503,21 @@ vl_mem_api_init (const char *region_name) if ((rv = vl_map_shmem (region_name, 1 /* is_vlib */ )) < 0) return rv; -#define _(N,n,t) do { \ - c->id = VL_API_##N; \ - c->name = #n; \ - c->handler = vl_api_##n##_t_handler; \ - c->cleanup = vl_noop_handler; \ - c->endian = vl_api_##n##_t_endian; \ - c->print = vl_api_##n##_t_print; \ - c->size = sizeof(vl_api_##n##_t); \ - c->traced = t; /* trace, so these msgs print */ \ - c->replay = 0; /* don't replay client create/delete msgs */ \ - c->message_bounce = 0; /* don't bounce this message */ \ - vl_msg_api_config(c);} while (0); +#define _(N, n, t) \ + do \ + { \ + c->id = VL_API_##N; \ + c->name = #n; \ + c->handler = vl_api_##n##_t_handler; \ + c->endian = vl_api_##n##_t_endian; \ + c->format_fn = vl_api_##n##_t_format; \ + c->size = sizeof (vl_api_##n##_t); \ + c->traced = t; /* trace, so these msgs print */ \ + c->replay = 0; /* don't replay client create/delete msgs */ \ + c->message_bounce = 0; /* don't bounce this message */ \ + vl_msg_api_config (c); \ + } \ + while (0); foreach_vlib_api_msg; #undef _ @@ -770,7 +772,6 @@ vl_mem_api_handler_with_vm_node (api_main_t *am, svm_region_t *vlib_rp, u16 id = clib_net_to_host_u16 (*((u16 *) the_msg)); vl_api_msg_data_t *m = vl_api_get_msg_data (am, id); u8 *(*handler) (void *, void *, void *); - u8 *(*print_fp) (void *, void *); svm_region_t *old_vlib_rp; void *save_shmem_hdr; int is_mp_safe = 1; @@ -802,15 +803,7 @@ vl_mem_api_handler_with_vm_node (api_main_t *am, svm_region_t *vlib_rp, if (PREDICT_FALSE (am->msg_print_flag)) { fformat (stdout, "[%d]: %s\n", id, m->name); - print_fp = (void *) am->msg_data[id].print_handler; - if (print_fp == 0) - { - fformat (stdout, " [no registered print fn for msg %d]\n", id); - } - else - { - (*print_fp) (the_msg, vm); - } + fformat (stdout, "%U", format_vl_api_msg_text, am, id, the_msg); } is_mp_safe = am->msg_data[id].is_mp_safe; |