diff options
author | Dave Barach <dave@barachs.net> | 2020-04-04 10:05:48 -0400 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2020-08-13 17:20:36 +0000 |
commit | d13034a6d1a239af07948ebe6a399c6aec5ddbbc (patch) | |
tree | 51534d97091bf18d77f07756c1bd35d893d56aa9 /src/vnet | |
parent | 11903b8db67d9de4d86cca856a8a32aa43f838f5 (diff) |
misc: sprintf be gone
Along with related static analysis warnings...
Type: fix
Ticket: VPP-1837
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I2c6949c7a2250b8f76a63508c7c210daecfe0f91
(cherry picked from commit 3e07a4a1e843267892dc291a833d93bd70597011)
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/dhcp/dhcp6_ia_na_client_cp.c | 25 | ||||
-rw-r--r-- | src/vnet/dhcp/dhcp6_pd_client_cp.c | 25 | ||||
-rw-r--r-- | src/vnet/session/application_worker.c | 7 |
3 files changed, 34 insertions, 23 deletions
diff --git a/src/vnet/dhcp/dhcp6_ia_na_client_cp.c b/src/vnet/dhcp/dhcp6_ia_na_client_cp.c index c5e4d0ce1da..78baf18cb40 100644 --- a/src/vnet/dhcp/dhcp6_ia_na_client_cp.c +++ b/src/vnet/dhcp/dhcp6_ia_na_client_cp.c @@ -582,8 +582,8 @@ dhcp6_clients_show_command_function (vlib_main_t * vm, clib_error_t *error = 0; client_state_t *cs; f64 current_time = vlib_time_now (vm); - char buf1[256]; - char buf2[256]; + u8 *buf1 = 0; + u8 *buf2 = 0; const char *rebinding; u32 i; @@ -592,26 +592,28 @@ dhcp6_clients_show_command_function (vlib_main_t * vm, cs = &rm->client_state_by_sw_if_index[i]; if (cs->enabled) { + vec_reset_length (buf1); + vec_reset_length (buf2); if (cs->T1_due_time != DBL_MAX && cs->T1_due_time > current_time) { - sprintf (buf1, "%u remaining", - (u32) round (cs->T1_due_time - current_time)); + buf1 = format (buf1, "%u remaining", + (u32) round (cs->T1_due_time - current_time)); } else - sprintf (buf1, "timeout"); + buf1 = format (buf1, "timeout"); if (cs->T2_due_time != DBL_MAX && cs->T2_due_time > current_time) - sprintf (buf2, "%u remaining", - (u32) round (cs->T2_due_time - current_time)); + buf2 = format (buf2, "%u remaining", + (u32) round (cs->T2_due_time - current_time)); else - sprintf (buf2, "timeout"); + buf2 = format (buf2, "timeout"); if (cs->rebinding) rebinding = ", REBINDING"; else rebinding = ""; if (cs->T1) vlib_cli_output (vm, - "sw_if_index: %u, T1: %u (%s), " - "T2: %u (%s), server index: %d%s", i, + "sw_if_index: %u, T1: %u (%v), " + "T2: %u (%v), server index: %d%s", i, cs->T1, buf1, cs->T2, buf2, cs->server_index, rebinding); else @@ -619,6 +621,9 @@ dhcp6_clients_show_command_function (vlib_main_t * vm, } } + vec_free (buf1); + vec_free (buf2); + return error; } diff --git a/src/vnet/dhcp/dhcp6_pd_client_cp.c b/src/vnet/dhcp/dhcp6_pd_client_cp.c index 0b1b707981a..984b74ad6ec 100644 --- a/src/vnet/dhcp/dhcp6_pd_client_cp.c +++ b/src/vnet/dhcp/dhcp6_pd_client_cp.c @@ -1118,8 +1118,8 @@ ip6_pd_clients_show_command_function (vlib_main_t * vm, client_state_t *cs; f64 current_time = vlib_time_now (vm); const u8 *prefix_group; - char buf1[256]; - char buf2[256]; + u8 *buf1 = 0; + u8 *buf2 = 0; const char *rebinding; u32 i; @@ -1128,18 +1128,20 @@ ip6_pd_clients_show_command_function (vlib_main_t * vm, cs = &rm->client_state_by_sw_if_index[i]; if (cs->enabled) { + vec_reset_length (buf1); + vec_reset_length (buf2); if (cs->T1_due_time != DBL_MAX && cs->T1_due_time > current_time) { - sprintf (buf1, "%u remaining", - (u32) round (cs->T1_due_time - current_time)); + buf1 = format (buf1, "%u remaining", + (u32) round (cs->T1_due_time - current_time)); } else - sprintf (buf1, "timeout"); + buf1 = format (buf1, "timeout"); if (cs->T2_due_time != DBL_MAX && cs->T2_due_time > current_time) - sprintf (buf2, "%u remaining", - (u32) round (cs->T2_due_time - current_time)); + buf2 = format (buf2, "%u remaining", + (u32) round (cs->T2_due_time - current_time)); else - sprintf (buf2, "timeout"); + buf2 = format (buf2, "timeout"); if (cs->rebinding) rebinding = ", REBINDING"; else @@ -1148,8 +1150,8 @@ ip6_pd_clients_show_command_function (vlib_main_t * vm, pm->prefix_group_name_by_index[cs->prefix_group_index]; if (cs->T1) vlib_cli_output (vm, - "sw_if_index: %u, prefix group: %s, T1: %u (%s), " - "T2: %u (%s), server index: %d%s", i, + "sw_if_index: %u, prefix group: %s, T1: %u (%v), " + "T2: %u (%v), server index: %d%s", i, prefix_group, cs->T1, buf1, cs->T2, buf2, cs->server_index, rebinding); else @@ -1158,6 +1160,9 @@ ip6_pd_clients_show_command_function (vlib_main_t * vm, } } + vec_free (buf1); + vec_free (buf2); + return error; } diff --git a/src/vnet/session/application_worker.c b/src/vnet/session/application_worker.c index f4321edb09f..49c76b8d354 100644 --- a/src/vnet/session/application_worker.c +++ b/src/vnet/session/application_worker.c @@ -676,10 +676,11 @@ format_app_worker_listener (u8 * s, va_list * args) if (verbose) { - char buf[32]; - sprintf (buf, "%u(%u)", app_wrk->wrk_map_index, app_wrk->wrk_index); - s = format (s, "%-40s%-25s%=10s%-15u%-15u%-10u", str, app_name, + u8 *buf; + buf = format (0, "%u(%u)", app_wrk->wrk_map_index, app_wrk->wrk_index); + s = format (s, "%-40s%-25s%=10v%-15u%-15u%-10u", str, app_name, buf, app_wrk->api_client_index, handle, sm_index); + vec_free (buf); } else s = format (s, "%-40s%-25s%=10u", str, app_name, app_wrk->wrk_map_index); |