c11 safe string handling support

Change-Id: Ied34720ca5a6e6e717eea4e86003e854031b6eab
Signed-off-by: Dave Barach <dave@barachs.net>
diff --git a/src/tests/vnet/lisp-cp/test_cp_serdes.c b/src/tests/vnet/lisp-cp/test_cp_serdes.c
index 8e8c845..11d29d0 100644
--- a/src/tests/vnet/lisp-cp/test_cp_serdes.c
+++ b/src/tests/vnet/lisp-cp/test_cp_serdes.c
@@ -69,7 +69,7 @@
   int lp = 0x15, rp = 0x14;
 
   b = clib_mem_alloc (buff_len);
-  memset((u8 *)b, 0, buff_len);
+  clib_memset((u8 *)b, 0, buff_len);
   b->current_length = buff_len;
   b->current_data = sizeof(udp_header_t) + sizeof(ip4_header_t) +
     sizeof(ecm_hdr_t) + 1;
@@ -91,7 +91,7 @@
 
   ip4_header_t * ih = (ip4_header_t *) (lh + 1);
   /* clear ip checksum */
-  memset((u8 *)ih + 10, 0, 2);
+  clib_memset((u8 *)ih + 10, 0, 2);
 
   u8 expected_ip4_hdr[] = {
     0x45,                   /* version; IHL */
@@ -109,7 +109,7 @@
 
   udp_header_t * uh = (udp_header_t *) (ih + 1);
   /* clear udp checksum */
-  memset((u8 *)uh + 6, 0, 2);
+  clib_memset((u8 *)uh + 6, 0, 2);
 
   u8 expected_udp_hdr[] = {
     0x00, 0x15, /* src port */
@@ -134,7 +134,7 @@
   u32 buff_len = 500;
 
   b = clib_mem_alloc (buff_len);
-  memset((u8 *)b, 0, buff_len);
+  clib_memset((u8 *)b, 0, buff_len);
 
   u8 map_reply_records[] = {
     /* 1. record */
@@ -184,8 +184,8 @@
   u8 rloc_probe_set = 0;
   u64 nonce = 0;
   map_request_hdr_t * h = 0;
-  memset (deid, 0, sizeof (deid[0]));
-  memset (seid, 0, sizeof (seid[0]));
+  clib_memset (deid, 0, sizeof (deid[0]));
+  clib_memset (seid, 0, sizeof (seid[0]));
 
   gid_address_type (seid) = GID_ADDR_IP_PREFIX;
   ip_address_t * ip_addr = &gid_address_ip (seid);
@@ -208,7 +208,7 @@
 generate_rlocs (gid_address_t **rlocs, u32 * count)
 {
   gid_address_t gid_addr_data, * gid_addr = &gid_addr_data;
-  memset (gid_addr, 0, sizeof (gid_addr[0]));
+  clib_memset (gid_addr, 0, sizeof (gid_addr[0]));
   ip_address_t * addr = &gid_address_ip (gid_addr);
 
   gid_address_type (gid_addr) = GID_ADDR_IP_PREFIX;
@@ -237,7 +237,7 @@
   u32 rloc_count_parse = 0;
 
   u8 * data = clib_mem_alloc(500);
-  memset(data, 0, 500);
+  clib_memset(data, 0, 500);
   b = (vlib_buffer_t *) data;
 
   generate_rlocs (&rlocs_decode, &rloc_count_parse);
@@ -297,12 +297,12 @@
   vec_add1 (rlocs, g);
 
   u8 * data = clib_mem_alloc (500);
-  memset (data, 0, 500);
+  clib_memset (data, 0, 500);
 
   h = build_map_request (lcm, (vlib_buffer_t *) data, rlocs);
 
   /* clear Nonce to simplify comparison */
-  memset ((u8 *)h + 4, 0, 8);
+  clib_memset ((u8 *)h + 4, 0, 8);
 
   u8 expected_data[] =
     {
@@ -346,13 +346,13 @@
   u32 rloc_count = 0;
 
   u8 * data = clib_mem_alloc(500);
-  memset(data, 0, 500);
+  clib_memset(data, 0, 500);
 
   generate_rlocs (&rlocs, &rloc_count);
   h = build_map_request (lcm, (vlib_buffer_t *) data, rlocs);
 
   /* clear Nonce to simplify comparison */
-  memset((u8 *)h + 4, 0, 8);
+  clib_memset((u8 *)h + 4, 0, 8);
 
   print_map_request(h);
 
@@ -441,7 +441,7 @@
   mapping_t * records = build_test_map_records ();
 
   u8 * data = clib_mem_alloc(500);
-  memset(data, 0, 500);
+  clib_memset(data, 0, 500);
   b = (vlib_buffer_t *) data;
 
   lisp_msg_put_map_register (b, records, 1 /* want map notify */,
@@ -450,10 +450,10 @@
   free_test_map_records (records);
 
   /* clear Nonce to simplify comparison */
-  memset((u8 *)b->data + 4, 0, 8);
+  clib_memset((u8 *)b->data + 4, 0, 8);
 
   /* clear authentication data */
-  memset ((u8 *)b->data + 16, 0, 20);
+  clib_memset ((u8 *)b->data + 16, 0, 20);
 
   u8 expected_data[] = {
     0x30, 0x00, 0x01, 0x01, /* type; rsvd; want notify; REC count */
@@ -492,7 +492,7 @@
   vlib_buffer_t *b;
 
   u8 *buf_data = clib_mem_alloc(500);
-  memset (buf_data, 0, 500);
+  clib_memset (buf_data, 0, 500);
   b = (vlib_buffer_t *)buf_data;
 
   u8 * p = vlib_buffer_put_uninit (b, data_len);
@@ -545,7 +545,7 @@
   u32 buff_len = 500;
 
   b = clib_mem_alloc (buff_len);
-  memset ((u8 *)b, 0, buff_len);
+  clib_memset ((u8 *)b, 0, buff_len);
 
   u8 map_reply_records[] =
     {
diff --git a/src/tests/vnet/lisp-cp/test_lisp_types.c b/src/tests/vnet/lisp-cp/test_lisp_types.c
index 7c55a9c..ff25a3f 100644
--- a/src/tests/vnet/lisp-cp/test_lisp_types.c
+++ b/src/tests/vnet/lisp-cp/test_lisp_types.c
@@ -133,7 +133,7 @@
   clib_error_t * error = 0;
 
   u8 * b = clib_mem_alloc(500);
-  memset(b, 0, 500);
+  clib_memset(b, 0, 500);
 
   gid_address_t g =
     {
@@ -168,8 +168,8 @@
   gid_address_t _gid_addr, * gid_addr = &_gid_addr;
   gid_address_t _gid_addr_copy, * copy = &_gid_addr_copy;
 
-  memset (gid_addr, 0, sizeof (gid_addr[0]));
-  memset (copy, 0, sizeof (copy[0]));
+  clib_memset (gid_addr, 0, sizeof (gid_addr[0]));
+  clib_memset (copy, 0, sizeof (copy[0]));
 
   u8 data[] =
     {
@@ -201,8 +201,8 @@
   gid_address_t _gid_addr, * gid_addr = &_gid_addr;
   gid_address_t _gid_addr_copy, * gid_addr_copy = &_gid_addr_copy;
 
-  memset (gid_addr, 0, sizeof (gid_addr[0]));
-  memset (gid_addr_copy, 0, sizeof (gid_addr_copy[0]));
+  clib_memset (gid_addr, 0, sizeof (gid_addr[0]));
+  clib_memset (gid_addr_copy, 0, sizeof (gid_addr_copy[0]));
 
   u8 data[] =
     {
@@ -241,8 +241,8 @@
   gid_address_t _gid_addr, * gid_addr = &_gid_addr;
   gid_address_t _gid_addr_copy, * gid_addr_copy = &_gid_addr_copy;
 
-  memset (gid_addr, 0, sizeof (gid_addr[0]));
-  memset (gid_addr_copy, 0, sizeof (gid_addr_copy[0]));
+  clib_memset (gid_addr, 0, sizeof (gid_addr[0]));
+  clib_memset (gid_addr_copy, 0, sizeof (gid_addr_copy[0]));
 
   u8 data[] =
     {
@@ -335,7 +335,7 @@
   clib_error_t * error = 0;
 
   u8 * b = clib_mem_alloc(500);
-  memset(b, 0, 500);
+  clib_memset(b, 0, 500);
 
   gid_address_t g =
     {
@@ -373,7 +373,7 @@
   clib_error_t * error = 0;
 
   u8 * b = clib_mem_alloc(500);
-  memset(b, 0, 500);
+  clib_memset(b, 0, 500);
 
   gid_address_t g =
     {
@@ -401,7 +401,7 @@
 {
   clib_error_t * error = 0;
   u8 * b = clib_mem_alloc (500);
-  memset (b, 0, 500);
+  clib_memset (b, 0, 500);
 
   fid_address_t src =
     {
@@ -472,7 +472,7 @@
   _assert (0 == memcmp (expected_data, b, sizeof (expected_data)));
 
   gid_address_t p;
-  memset (&p, 0, sizeof (p));
+  clib_memset (&p, 0, sizeof (p));
   _assert (write_len == gid_address_parse (b, &p));
   _assert (0 == gid_address_cmp (&g, &p));
 done:
@@ -512,7 +512,7 @@
   clib_error_t * error = 0;
 
   u8 * b = clib_mem_alloc (500);
-  memset (b, 0, 500);
+  clib_memset (b, 0, 500);
 
   fid_address_t src =
     {
@@ -564,7 +564,7 @@
   _assert (0 == memcmp (expected_data, b, sizeof (expected_data)));
 
   gid_address_t p;
-  memset (&p, 0, sizeof (p));
+  clib_memset (&p, 0, sizeof (p));
   _assert (write_len == gid_address_parse (b, &p));
   _assert (0 == gid_address_cmp (&g, &p));
 done:
@@ -578,7 +578,7 @@
   ip_prefix_t ippref_data, * ippref = &ippref_data;
 
   u8 * b = clib_mem_alloc(500);
-  memset(b, 0, 500);
+  clib_memset(b, 0, 500);
 
   ip_prefix_version (ippref) = IP4;
   ip_prefix_len (ippref) = 9;
diff --git a/src/tests/vnet/session/tcp_echo.c b/src/tests/vnet/session/tcp_echo.c
index 140a198..1a0df31 100644
--- a/src/tests/vnet/session/tcp_echo.c
+++ b/src/tests/vnet/session/tcp_echo.c
@@ -284,7 +284,7 @@
   vl_api_application_tls_key_add_t *key_mp;
 
   bmp = vl_msg_api_alloc (sizeof (*bmp));
-  memset (bmp, 0, sizeof (*bmp));
+  clib_memset (bmp, 0, sizeof (*bmp));
 
   bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_ATTACH);
   bmp->client_index = em->my_client_index;
@@ -301,7 +301,7 @@
   vl_msg_api_send_shmem (em->vl_input_queue, (u8 *) & bmp);
 
   cert_mp = vl_msg_api_alloc (sizeof (*cert_mp) + test_srv_crt_rsa_len);
-  memset (cert_mp, 0, sizeof (*cert_mp));
+  clib_memset (cert_mp, 0, sizeof (*cert_mp));
   cert_mp->_vl_msg_id = ntohs (VL_API_APPLICATION_TLS_CERT_ADD);
   cert_mp->client_index = em->my_client_index;
   cert_mp->context = ntohl (0xfeedface);
@@ -310,7 +310,7 @@
   vl_msg_api_send_shmem (em->vl_input_queue, (u8 *) & cert_mp);
 
   key_mp = vl_msg_api_alloc (sizeof (*key_mp) + test_srv_key_rsa_len);
-  memset (key_mp, 0, sizeof (*key_mp) + test_srv_key_rsa_len);
+  clib_memset (key_mp, 0, sizeof (*key_mp) + test_srv_key_rsa_len);
   key_mp->_vl_msg_id = ntohs (VL_API_APPLICATION_TLS_KEY_ADD);
   key_mp->client_index = em->my_client_index;
   key_mp->context = ntohl (0xfeedface);
@@ -336,7 +336,7 @@
 {
   vl_api_application_detach_t *bmp;
   bmp = vl_msg_api_alloc (sizeof (*bmp));
-  memset (bmp, 0, sizeof (*bmp));
+  clib_memset (bmp, 0, sizeof (*bmp));
 
   bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_DETACH);
   bmp->client_index = em->my_client_index;
@@ -352,7 +352,7 @@
   svm_fifo_segment_create_args_t _a, *a = &_a;
   int rv;
 
-  memset (a, 0, sizeof (*a));
+  clib_memset (a, 0, sizeof (*a));
   a->segment_name = (char *) name;
   a->segment_type = type;
 
@@ -517,7 +517,7 @@
   svm_fifo_segment_create_args_t _a, *a = &_a;
   int rv;
 
-  memset (a, 0, sizeof (*a));
+  clib_memset (a, 0, sizeof (*a));
   a->segment_name = (char *) mp->segment_name;
   a->segment_size = mp->segment_size;
   /* Attach to the segment vpp created */
@@ -703,7 +703,7 @@
 {
   vl_api_connect_uri_t *cmp;
   cmp = vl_msg_api_alloc (sizeof (*cmp));
-  memset (cmp, 0, sizeof (*cmp));
+  clib_memset (cmp, 0, sizeof (*cmp));
 
   cmp->_vl_msg_id = ntohs (VL_API_CONNECT_URI);
   cmp->client_index = em->my_client_index;
@@ -717,7 +717,7 @@
 {
   vl_api_disconnect_session_t *dmp;
   dmp = vl_msg_api_alloc (sizeof (*dmp));
-  memset (dmp, 0, sizeof (*dmp));
+  clib_memset (dmp, 0, sizeof (*dmp));
   dmp->_vl_msg_id = ntohs (VL_API_DISCONNECT_SESSION);
   dmp->client_index = em->my_client_index;
   dmp->handle = s->vpp_session_handle;
@@ -729,7 +729,7 @@
 {
   client_send_disconnect (em, s);
   pool_put (em->sessions, s);
-  memset (s, 0xfe, sizeof (*s));
+  clib_memset (s, 0xfe, sizeof (*s));
   return 0;
 }
 
@@ -816,7 +816,7 @@
    */
 
   pool_get (em->sessions, session);
-  memset (session, 0, sizeof (*session));
+  clib_memset (session, 0, sizeof (*session));
   session_index = session - em->sessions;
 
   rx_fifo = uword_to_pointer (mp->server_rx_fifo, svm_fifo_t *);
@@ -1232,7 +1232,7 @@
 {
   vl_api_bind_uri_t *bmp;
   bmp = vl_msg_api_alloc (sizeof (*bmp));
-  memset (bmp, 0, sizeof (*bmp));
+  clib_memset (bmp, 0, sizeof (*bmp));
 
   bmp->_vl_msg_id = ntohs (VL_API_BIND_URI);
   bmp->client_index = em->my_client_index;
@@ -1259,7 +1259,7 @@
   vl_api_unbind_uri_t *ump;
 
   ump = vl_msg_api_alloc (sizeof (*ump));
-  memset (ump, 0, sizeof (*ump));
+  clib_memset (ump, 0, sizeof (*ump));
 
   ump->_vl_msg_id = ntohs (VL_API_UNBIND_URI);
   ump->client_index = em->my_client_index;
@@ -1289,7 +1289,7 @@
   for (i = 0; i < 200000; i++)
     {
       pool_get (em->sessions, session);
-      memset (session, 0, sizeof (*session));
+      clib_memset (session, 0, sizeof (*session));
     }
   for (i = 0; i < 200000; i++)
     pool_put_index (em->sessions, i);
@@ -1395,7 +1395,7 @@
 
   clib_mem_init_thread_safe (0, 256 << 20);
 
-  memset (em, 0, sizeof (*em));
+  clib_memset (em, 0, sizeof (*em));
   em->session_index_by_vpp_handles = hash_create (0, sizeof (uword));
   em->my_pid = getpid ();
   em->configured_segment_size = 1 << 20;
diff --git a/src/tests/vnet/session/udp_echo.c b/src/tests/vnet/session/udp_echo.c
index 9872eed..9ab7751 100644
--- a/src/tests/vnet/session/udp_echo.c
+++ b/src/tests/vnet/session/udp_echo.c
@@ -302,7 +302,7 @@
 {
   vl_api_application_attach_t *bmp;
   bmp = vl_msg_api_alloc (sizeof (*bmp));
-  memset (bmp, 0, sizeof (*bmp));
+  clib_memset (bmp, 0, sizeof (*bmp));
 
   bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_ATTACH);
   bmp->client_index = utm->my_client_index;
@@ -325,7 +325,7 @@
 {
   vl_api_application_detach_t *bmp;
   bmp = vl_msg_api_alloc (sizeof (*bmp));
-  memset (bmp, 0, sizeof (*bmp));
+  clib_memset (bmp, 0, sizeof (*bmp));
 
   bmp->_vl_msg_id = ntohs (VL_API_APPLICATION_DETACH);
   bmp->client_index = utm->my_client_index;
@@ -508,7 +508,7 @@
   tx_fifo = uword_to_pointer (mp->server_tx_fifo, svm_fifo_t *);
 
   pool_get (utm->sessions, session);
-  memset (session, 0, sizeof (*session));
+  clib_memset (session, 0, sizeof (*session));
   session_index = session - utm->sessions;
   session->session_index = session_index;
 
@@ -687,7 +687,7 @@
   tx_fifo = uword_to_pointer (mp->tx_fifo, svm_fifo_t *);
 
   pool_get (utm->sessions, session);
-  memset (session, 0, sizeof (*session));
+  clib_memset (session, 0, sizeof (*session));
   session_index = session - utm->sessions;
 
   rx_fifo->client_session_index = session_index;
@@ -730,7 +730,7 @@
 {
   vl_api_connect_uri_t *cmp;
   cmp = vl_msg_api_alloc (sizeof (*cmp));
-  memset (cmp, 0, sizeof (*cmp));
+  clib_memset (cmp, 0, sizeof (*cmp));
 
   cmp->_vl_msg_id = ntohs (VL_API_CONNECT_URI);
   cmp->client_index = utm->my_client_index;
@@ -894,7 +894,7 @@
   tx_fifo = uword_to_pointer (mp->tx_fifo, svm_fifo_t *);
 
   pool_get (utm->sessions, session);
-  memset (session, 0, sizeof (*session));
+  clib_memset (session, 0, sizeof (*session));
   session_index = session - utm->sessions;
 
   rx_fifo->client_session_index = session_index;
@@ -919,7 +919,7 @@
   u8 *seg_name;
   int rv;
 
-  memset (a, 0, sizeof (*a));
+  clib_memset (a, 0, sizeof (*a));
   a->segment_name = (char *) mp->segment_name;
   a->segment_size = mp->segment_size;
   /* Attach to the segment vpp created */
@@ -1154,7 +1154,7 @@
   vl_api_unbind_uri_t *ump;
 
   ump = vl_msg_api_alloc (sizeof (*ump));
-  memset (ump, 0, sizeof (*ump));
+  clib_memset (ump, 0, sizeof (*ump));
 
   ump->_vl_msg_id = ntohs (VL_API_UNBIND_URI);
   ump->client_index = utm->my_client_index;
@@ -1168,7 +1168,7 @@
   vl_api_bind_uri_t *bmp;
 
   bmp = vl_msg_api_alloc (sizeof (*bmp));
-  memset (bmp, 0, sizeof (*bmp));
+  clib_memset (bmp, 0, sizeof (*bmp));
 
   bmp->_vl_msg_id = ntohs (VL_API_BIND_URI);
   bmp->client_index = utm->my_client_index;
@@ -1303,7 +1303,7 @@
   for (i = 0; i < 200000; i++)
     {
       pool_get (utm->sessions, session);
-      memset (session, 0, sizeof (*session));
+      clib_memset (session, 0, sizeof (*session));
     }
   for (i = 0; i < 200000; i++)
     pool_put_index (utm->sessions, i);