aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlibmemory/memory_client.c
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2019-08-22 09:02:59 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2019-08-27 07:51:55 +0000
commit2959d42feb576c0e00c28c4e27658b25f6c783e9 (patch)
tree9b1e3474eb835b4fac2e3edfbcbda9a02a8cc730 /src/vlibmemory/memory_client.c
parent3f1964d2d2847c5307694fe8daea0a7eef1e2733 (diff)
api: use string type for strings in memclnt.api
Explicitly using string type in API allows for autogenerating tools to print strings instead of hex-dumping byte strings. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: I573962d6b34d5d10aab9dc6a5fdf101c9b12a6a6 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vlibmemory/memory_client.c')
-rw-r--r--src/vlibmemory/memory_client.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c
index f032ae77d19..3e1bdff777c 100644
--- a/src/vlibmemory/memory_client.c
+++ b/src/vlibmemory/memory_client.c
@@ -195,7 +195,7 @@ vl_client_connect (const char *name, int ctx_quota, int input_queue_size)
mp->_vl_msg_id = ntohs (VL_API_MEMCLNT_CREATE);
mp->ctx_quota = ctx_quota;
mp->input_queue = (uword) vl_input_queue;
- strncpy ((char *) mp->name, name, sizeof (mp->name) - 1);
+ vl_api_to_api_string (strnlen_s (name, 64), name, &mp->name);
vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & mp);
@@ -517,7 +517,8 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
clib_time_t clib_time;
u16 rv = ~0;
- if (strlen (plugin_name) + 1 > sizeof (mp->name))
+ size_t plugin_name_len = strnlen_s (plugin_name, 128);
+ if (plugin_name_len == 128)
return (rv);
clib_memset (&clib_time, 0, sizeof (clib_time));
@@ -538,7 +539,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID);
mp->client_index = am->my_client_index;
- strncpy ((char *) mp->name, plugin_name, sizeof (mp->name) - 1);
+ vl_api_to_api_string (plugin_name_len, plugin_name, &mp->name);
if (vl_socket_client_write () <= 0)
goto sock_err;
@@ -563,7 +564,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID);
mp->client_index = am->my_client_index;
- strncpy ((char *) mp->name, plugin_name, sizeof (mp->name) - 1);
+ vl_api_to_api_string (plugin_name_len, plugin_name, &mp->name);
vl_msg_api_send_shmem (am->shmem_hdr->vl_input_queue, (u8 *) & mp);