From b7b929931a07fbb27b43d5cd105f366c3e29807e Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Wed, 17 Oct 2018 10:38:51 -0400 Subject: c11 safe string handling support Change-Id: Ied34720ca5a6e6e717eea4e86003e854031b6eab Signed-off-by: Dave Barach --- src/vnet/devices/af_packet/af_packet.c | 6 +++--- src/vnet/devices/af_packet/af_packet_api.c | 2 +- src/vnet/devices/netlink.c | 2 +- src/vnet/devices/netmap/netmap.c | 4 ++-- src/vnet/devices/pipe/pipe.c | 4 ++-- src/vnet/devices/tap/tap.c | 10 +++++----- src/vnet/devices/tap/tapv2_api.c | 6 +++--- src/vnet/devices/virtio/device.c | 2 +- src/vnet/devices/virtio/vhost_user.c | 8 ++++---- src/vnet/devices/virtio/vhost_user_api.c | 4 ++-- src/vnet/devices/virtio/vhost_user_input.c | 2 +- src/vnet/devices/virtio/vhost_user_output.c | 2 +- src/vnet/devices/virtio/virtio.c | 6 +++--- 13 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src/vnet/devices') diff --git a/src/vnet/devices/af_packet/af_packet.c b/src/vnet/devices/af_packet/af_packet.c index f1a7b6ad21c..e58f2782765 100644 --- a/src/vnet/devices/af_packet/af_packet.c +++ b/src/vnet/devices/af_packet/af_packet.c @@ -143,7 +143,7 @@ create_packet_v2_sock (int host_if_index, tpacket_req_t * rx_req, } /* bind before rx ring is cfged so we don't receive packets from other interfaces */ - memset (&sll, 0, sizeof (sll)); + clib_memset (&sll, 0, sizeof (sll)); sll.sll_family = PF_PACKET; sll.sll_protocol = htons (ETH_P_ALL); sll.sll_ifindex = host_if_index; @@ -350,7 +350,7 @@ af_packet_create_if (vlib_main_t * vm, u8 * host_if_name, u8 * hw_addr_set, if (error) { - memset (apif, 0, sizeof (*apif)); + clib_memset (apif, 0, sizeof (*apif)); pool_put (apm->interfaces, apif); vlib_log_err (apm->log_class, "Unable to register interface: %U", format_clib_error, error); @@ -502,7 +502,7 @@ af_packet_init (vlib_main_t * vm) af_packet_main_t *apm = &af_packet_main; vlib_thread_main_t *tm = vlib_get_thread_main (); - memset (apm, 0, sizeof (af_packet_main_t)); + clib_memset (apm, 0, sizeof (af_packet_main_t)); mhash_init_vec_string (&apm->if_index_by_host_if_name, sizeof (uword)); diff --git a/src/vnet/devices/af_packet/af_packet_api.c b/src/vnet/devices/af_packet/af_packet_api.c index 3e03b5917fe..3dc18b1e96a 100644 --- a/src/vnet/devices/af_packet/af_packet_api.c +++ b/src/vnet/devices/af_packet/af_packet_api.c @@ -111,7 +111,7 @@ af_packet_send_details (vpe_api_main_t * am, { vl_api_af_packet_details_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = htons (VL_API_AF_PACKET_DETAILS); mp->sw_if_index = htonl (af_packet_if->sw_if_index); clib_memcpy (mp->host_if_name, af_packet_if->host_if_name, diff --git a/src/vnet/devices/netlink.c b/src/vnet/devices/netlink.c index 1d44f287bdc..a954fef74fd 100644 --- a/src/vnet/devices/netlink.c +++ b/src/vnet/devices/netlink.c @@ -38,7 +38,7 @@ vnet_netlink_msg_init (vnet_netlink_msg_t * m, u16 type, u16 flags, { struct nlmsghdr *nh; u8 *p; - memset (m, 0, sizeof (vnet_netlink_msg_t)); + clib_memset (m, 0, sizeof (vnet_netlink_msg_t)); vec_add2 (m->data, p, NLMSG_SPACE (msg_len)); ASSERT (m->data == p); diff --git a/src/vnet/devices/netmap/netmap.c b/src/vnet/devices/netmap/netmap.c index 25a3af73451..03d96216bb0 100644 --- a/src/vnet/devices/netmap/netmap.c +++ b/src/vnet/devices/netmap/netmap.c @@ -80,7 +80,7 @@ close_netmap_if (netmap_main_t * nm, netmap_if_t * nif) vec_free (nif->host_if_name); vec_free (nif->req); - memset (nif, 0, sizeof (*nif)); + clib_memset (nif, 0, sizeof (*nif)); pool_put (nm->interfaces, nif); } @@ -280,7 +280,7 @@ netmap_init (vlib_main_t * vm) vlib_thread_registration_t *tr; uword *p; - memset (nm, 0, sizeof (netmap_main_t)); + clib_memset (nm, 0, sizeof (netmap_main_t)); nm->input_cpu_first_index = 0; nm->input_cpu_count = 1; diff --git a/src/vnet/devices/pipe/pipe.c b/src/vnet/devices/pipe/pipe.c index 6154a66f5c4..8b30f4705d6 100644 --- a/src/vnet/devices/pipe/pipe.c +++ b/src/vnet/devices/pipe/pipe.c @@ -527,7 +527,7 @@ pipe_create_sub_interface (vnet_hw_interface_t * hi, { vnet_sw_interface_t template; - memset (&template, 0, sizeof (template)); + clib_memset (&template, 0, sizeof (template)); template.type = VNET_SW_INTERFACE_TYPE_PIPE; template.flood_class = VNET_FLOOD_CLASS_NORMAL; template.sup_sw_if_index = hi->sw_if_index; @@ -557,7 +557,7 @@ vnet_create_pipe_interface (u8 is_specified, ASSERT (parent_sw_if_index); - memset (address, 0, sizeof (address)); + clib_memset (address, 0, sizeof (address)); /* * Allocate a pipe instance. Either select one dynamically diff --git a/src/vnet/devices/tap/tap.c b/src/vnet/devices/tap/tap.c index d3ed2af18fd..3bbdd05cd4d 100644 --- a/src/vnet/devices/tap/tap.c +++ b/src/vnet/devices/tap/tap.c @@ -115,7 +115,7 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args) return; } - memset (&ifr, 0, sizeof (ifr)); + clib_memset (&ifr, 0, sizeof (ifr)); pool_get (vim->interfaces, vif); vif->dev_instance = vif - vim->interfaces; vif->tap_fd = -1; @@ -317,7 +317,7 @@ tap_create_if (vlib_main_t * vm, tap_create_if_args_t * args) /* Set vhost memory table */ i = sizeof (struct vhost_memory) + sizeof (struct vhost_memory_region); vhost_mem = clib_mem_alloc (i); - memset (vhost_mem, 0, i); + clib_memset (vhost_mem, 0, i); vhost_mem->nregions = 1; vhost_mem->regions[0].memory_size = (1ULL << 47) - 4096; _IOCTL (vif->fd, VHOST_SET_MEM_TABLE, vhost_mem); @@ -405,7 +405,7 @@ error: close (vif->fd); vec_foreach_index (i, vif->vrings) virtio_vring_free (vm, vif, i); vec_free (vif->vrings); - memset (vif, 0, sizeof (virtio_if_t)); + clib_memset (vif, 0, sizeof (virtio_if_t)); pool_put (vim->interfaces, vif); done: @@ -449,7 +449,7 @@ tap_delete_if (vlib_main_t * vm, u32 sw_if_index) tm->tap_ids = clib_bitmap_set (tm->tap_ids, vif->id, 0); clib_spinlock_free (&vif->lockp); - memset (vif, 0, sizeof (*vif)); + clib_memset (vif, 0, sizeof (*vif)); pool_put (mm->interfaces, vif); return 0; @@ -468,7 +468,7 @@ tap_dump_ifs (tap_interface_details_t ** out_tapids) /* *INDENT-OFF* */ pool_foreach (vif, mm->interfaces, vec_add2(r_tapids, tapid, 1); - memset (tapid, 0, sizeof (*tapid)); + clib_memset (tapid, 0, sizeof (*tapid)); tapid->id = vif->id; tapid->sw_if_index = vif->sw_if_index; hi = vnet_get_hw_interface (vnm, vif->hw_if_index); diff --git a/src/vnet/devices/tap/tapv2_api.c b/src/vnet/devices/tap/tapv2_api.c index f0c980a64fa..e70d63f914f 100644 --- a/src/vnet/devices/tap/tapv2_api.c +++ b/src/vnet/devices/tap/tapv2_api.c @@ -58,7 +58,7 @@ vl_api_tap_create_v2_t_handler (vl_api_tap_create_v2_t * mp) vl_api_registration_t *reg; tap_create_if_args_t _a, *ap = &_a; - memset (ap, 0, sizeof (*ap)); + clib_memset (ap, 0, sizeof (*ap)); ap->id = ntohl (mp->id); if (!mp->use_random_mac) @@ -142,7 +142,7 @@ tap_send_sw_interface_event_deleted (vpe_api_main_t * am, vl_api_sw_interface_event_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT); mp->sw_if_index = ntohl (sw_if_index); @@ -190,7 +190,7 @@ tap_send_sw_interface_details (vpe_api_main_t * am, { vl_api_sw_interface_tap_v2_details_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_TAP_V2_DETAILS); mp->id = htonl (tap_if->id); mp->sw_if_index = htonl (tap_if->sw_if_index); diff --git a/src/vnet/devices/virtio/device.c b/src/vnet/devices/virtio/device.c index c7efe6519cd..9b01b9183c8 100644 --- a/src/vnet/devices/virtio/device.c +++ b/src/vnet/devices/virtio/device.c @@ -132,7 +132,7 @@ add_buffer_to_slot (vlib_main_t * vm, virtio_vring_t * vring, u32 bi, vlib_buffer_t *b = vlib_get_buffer (vm, bi); struct virtio_net_hdr_v1 *hdr = vlib_buffer_get_current (b) - hdr_sz; - memset (hdr, 0, hdr_sz); + clib_memset (hdr, 0, hdr_sz); if (PREDICT_TRUE ((b->flags & VLIB_BUFFER_NEXT_PRESENT) == 0)) { diff --git a/src/vnet/devices/virtio/vhost_user.c b/src/vnet/devices/virtio/vhost_user.c index 1342030a651..9725a91027d 100644 --- a/src/vnet/devices/virtio/vhost_user.c +++ b/src/vnet/devices/virtio/vhost_user.c @@ -307,7 +307,7 @@ static_always_inline void vhost_user_vring_init (vhost_user_intf_t * vui, u32 qid) { vhost_user_vring_t *vring = &vui->vrings[qid]; - memset (vring, 0, sizeof (*vring)); + clib_memset (vring, 0, sizeof (*vring)); vring->kickfd_idx = ~0; vring->callfd_idx = ~0; vring->errfd = -1; @@ -394,8 +394,8 @@ vhost_user_socket_read (clib_file_t * uf) char control[CMSG_SPACE (VHOST_MEMORY_MAX_NREGIONS * sizeof (int))]; - memset (&mh, 0, sizeof (mh)); - memset (control, 0, sizeof (control)); + clib_memset (&mh, 0, sizeof (mh)); + clib_memset (control, 0, sizeof (control)); for (i = 0; i < VHOST_MEMORY_MAX_NREGIONS; i++) fds[i] = -1; @@ -1419,7 +1419,7 @@ vhost_user_vui_init (vnet_main_t * vnm, { vui->vring_locks[q] = clib_mem_alloc_aligned (CLIB_CACHE_LINE_BYTES, CLIB_CACHE_LINE_BYTES); - memset ((void *) vui->vring_locks[q], 0, CLIB_CACHE_LINE_BYTES); + clib_memset ((void *) vui->vring_locks[q], 0, CLIB_CACHE_LINE_BYTES); } vec_validate (vui->per_cpu_tx_qid, diff --git a/src/vnet/devices/virtio/vhost_user_api.c b/src/vnet/devices/virtio/vhost_user_api.c index 016ccbd2687..b8d89a07cbc 100644 --- a/src/vnet/devices/virtio/vhost_user_api.c +++ b/src/vnet/devices/virtio/vhost_user_api.c @@ -58,7 +58,7 @@ send_sw_interface_event_deleted (vpe_api_main_t * am, vl_api_sw_interface_event_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT); mp->sw_if_index = ntohl (sw_if_index); @@ -165,7 +165,7 @@ send_sw_interface_vhost_user_details (vpe_api_main_t * am, vl_api_sw_interface_vhost_user_details_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_VHOST_USER_DETAILS); mp->sw_if_index = ntohl (vui->sw_if_index); mp->virtio_net_hdr_sz = ntohl (vui->virtio_net_hdr_sz); diff --git a/src/vnet/devices/virtio/vhost_user_input.c b/src/vnet/devices/virtio/vhost_user_input.c index 26140484d2e..291d687ab6a 100644 --- a/src/vnet/devices/virtio/vhost_user_input.c +++ b/src/vnet/devices/virtio/vhost_user_input.c @@ -101,7 +101,7 @@ vhost_user_rx_trace (vhost_trace_t * t, virtio_net_hdr_mrg_rxbuf_t *hdr; u32 hint = 0; - memset (t, 0, sizeof (*t)); + clib_memset (t, 0, sizeof (*t)); t->device_index = vui - vum->vhost_user_interfaces; t->qid = qid; diff --git a/src/vnet/devices/virtio/vhost_user_output.c b/src/vnet/devices/virtio/vhost_user_output.c index dab8fa5fb3b..820594999c8 100644 --- a/src/vnet/devices/virtio/vhost_user_output.c +++ b/src/vnet/devices/virtio/vhost_user_output.c @@ -155,7 +155,7 @@ vhost_user_tx_trace (vhost_trace_t * t, vring_desc_t *hdr_desc = 0; u32 hint = 0; - memset (t, 0, sizeof (*t)); + clib_memset (t, 0, sizeof (*t)); t->device_index = vui - vum->vhost_user_interfaces; t->qid = qid; diff --git a/src/vnet/devices/virtio/virtio.c b/src/vnet/devices/virtio/virtio.c index 072e8a755b0..17de781921d 100644 --- a/src/vnet/devices/virtio/virtio.c +++ b/src/vnet/devices/virtio/virtio.c @@ -85,19 +85,19 @@ virtio_vring_init (vlib_main_t * vm, virtio_if_t * vif, u16 idx, u16 sz) i = sizeof (struct vring_desc) * sz; i = round_pow2 (i, CLIB_CACHE_LINE_BYTES); vring->desc = clib_mem_alloc_aligned (i, CLIB_CACHE_LINE_BYTES); - memset (vring->desc, 0, i); + clib_memset (vring->desc, 0, i); i = sizeof (struct vring_avail) + sz * sizeof (vring->avail->ring[0]); i = round_pow2 (i, CLIB_CACHE_LINE_BYTES); vring->avail = clib_mem_alloc_aligned (i, CLIB_CACHE_LINE_BYTES); - memset (vring->avail, 0, i); + clib_memset (vring->avail, 0, i); // tell kernel that we don't need interrupt vring->avail->flags = VIRTIO_RING_FLAG_MASK_INT; i = sizeof (struct vring_used) + sz * sizeof (struct vring_used_elem); i = round_pow2 (i, CLIB_CACHE_LINE_BYTES); vring->used = clib_mem_alloc_aligned (i, CLIB_CACHE_LINE_BYTES); - memset (vring->used, 0, i); + clib_memset (vring->used, 0, i); ASSERT (vring->buffers == 0); vec_validate_aligned (vring->buffers, sz, CLIB_CACHE_LINE_BYTES); -- cgit 1.2.3-korg