c11 safe string handling support
Change-Id: Ied34720ca5a6e6e717eea4e86003e854031b6eab
Signed-off-by: Dave Barach <dave@barachs.net>
diff --git a/src/vnet/unix/pcap.c b/src/vnet/unix/pcap.c
index e91b879..3c9ce31 100644
--- a/src/vnet/unix/pcap.c
+++ b/src/vnet/unix/pcap.c
@@ -113,7 +113,7 @@
clib_spinlock_init (&pm->lock);
/* Write file header. */
- memset (&fh, 0, sizeof (fh));
+ clib_memset (&fh, 0, sizeof (fh));
fh.magic = 0xa1b2c3d4;
fh.major_version = 2;
fh.minor_version = 4;
diff --git a/src/vnet/unix/tap_api.c b/src/vnet/unix/tap_api.c
index 026a963..8437c6a 100644
--- a/src/vnet/unix/tap_api.c
+++ b/src/vnet/unix/tap_api.c
@@ -65,7 +65,7 @@
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);
@@ -87,7 +87,7 @@
u8 *tag;
vnet_tap_connect_args_t _a, *ap = &_a;
- memset (ap, 0, sizeof (*ap));
+ clib_memset (ap, 0, sizeof (*ap));
ap->intfc_name = mp->tap_name;
if (!mp->use_random_mac)
@@ -141,7 +141,7 @@
vlib_main_t *vm = vlib_get_main ();
vnet_tap_connect_args_t _a, *ap = &_a;
- memset (ap, 0, sizeof (*ap));
+ clib_memset (ap, 0, sizeof (*ap));
ap->orig_sw_if_index = ntohl (mp->sw_if_index);
ap->intfc_name = mp->tap_name;
@@ -206,7 +206,7 @@
{
vl_api_sw_interface_tap_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_TAP_DETAILS);
mp->sw_if_index = ntohl (tap_if->sw_if_index);
strncpy ((char *) mp->dev_name,
diff --git a/src/vnet/unix/tapcli.c b/src/vnet/unix/tapcli.c
index 00f093e..d183c3a 100644
--- a/src/vnet/unix/tapcli.c
+++ b/src/vnet/unix/tapcli.c
@@ -874,7 +874,7 @@
if ((dev_net_tun_fd = open ("/dev/net/tun", O_RDWR)) < 0)
return VNET_API_ERROR_SYSCALL_ERROR_1;
- memset (&ifr, 0, sizeof (ifr));
+ clib_memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, (char *) ap->intfc_name, sizeof (ifr.ifr_name) - 1);
ifr.ifr_flags = flags;
if (ioctl (dev_net_tun_fd, TUNSETIFF, (void *) &ifr) < 0)
@@ -895,7 +895,7 @@
struct ifreq ifr;
struct sockaddr_ll sll;
- memset (&ifr, 0, sizeof (ifr));
+ clib_memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, (char *) ap->intfc_name,
sizeof (ifr.ifr_name) - 1);
if (ioctl (dev_tap_fd, SIOCGIFINDEX, &ifr) < 0)
@@ -905,7 +905,7 @@
}
/* Bind the provisioning socket to the interface. */
- memset (&sll, 0, sizeof (sll));
+ clib_memset (&sll, 0, sizeof (sll));
sll.sll_family = AF_PACKET;
sll.sll_ifindex = ifr.ifr_ifindex;
sll.sll_protocol = htons (ETH_P_ALL);
@@ -954,7 +954,7 @@
/* ip4: mask defaults to /24 */
u32 mask = clib_host_to_net_u32 (0xFFFFFF00);
- memset (&sin, 0, sizeof (sin));
+ clib_memset (&sin, 0, sizeof (sin));
sin.sin_family = AF_INET;
/* sin.sin_port = 0; */
sin.sin_addr.s_addr = ap->ip4_address->as_u32;
@@ -998,7 +998,7 @@
goto error;
}
- memset (&ifr2, 0, sizeof (ifr));
+ clib_memset (&ifr2, 0, sizeof (ifr));
strncpy (ifr2.ifr_name, (char *) ap->intfc_name,
sizeof (ifr2.ifr_name) - 1);
if (ioctl (sockfd6, SIOCGIFINDEX, &ifr2) < 0)
@@ -1316,7 +1316,7 @@
user_hwaddr = 1;
- memset (ap, 0, sizeof (*ap));
+ clib_memset (ap, 0, sizeof (*ap));
ap->orig_sw_if_index = sw_if_index;
ap->intfc_name = intfc_name;
ap->sw_if_indexp = &new_sw_if_index;
@@ -1418,7 +1418,7 @@
goto done;
}
- memset (ap, 0, sizeof (*ap));
+ clib_memset (ap, 0, sizeof (*ap));
ap->intfc_name = intfc_name;
ap->hwaddr_arg = hwaddr_arg;
diff --git a/src/vnet/unix/tuntap.c b/src/vnet/unix/tuntap.c
index 4a9bd46..5f22592 100644
--- a/src/vnet/unix/tuntap.c
+++ b/src/vnet/unix/tuntap.c
@@ -445,7 +445,7 @@
if (sfd < 0)
clib_unix_warning ("provisioning socket");
- memset (&ifr, 0, sizeof (ifr));
+ clib_memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, tm->tun_name, sizeof (ifr.ifr_name) - 1);
/* get flags, modify to bring down interface... */
@@ -535,7 +535,7 @@
goto done;
}
- memset (&ifr, 0, sizeof (ifr));
+ clib_memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, tm->tun_name, sizeof (ifr.ifr_name) - 1);
ifr.ifr_flags = flags;
if (ioctl (tm->dev_net_tun_fd, TUNSETIFF, (void *) &ifr) < 0)
@@ -563,7 +563,7 @@
struct ifreq ifr;
struct sockaddr_ll sll;
- memset (&ifr, 0, sizeof (ifr));
+ clib_memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, tm->tun_name, sizeof (ifr.ifr_name) - 1);
if (ioctl (tm->dev_tap_fd, SIOCGIFINDEX, &ifr) < 0)
{
@@ -572,7 +572,7 @@
}
/* Bind the provisioning socket to the interface. */
- memset (&sll, 0, sizeof (sll));
+ clib_memset (&sll, 0, sizeof (sll));
sll.sll_family = AF_PACKET;
sll.sll_ifindex = ifr.ifr_ifindex;
sll.sll_protocol = htons (ETH_P_ALL);
@@ -719,7 +719,7 @@
return;
/** See if we already know about this subif */
- memset (&subif_addr, 0, sizeof (subif_addr));
+ clib_memset (&subif_addr, 0, sizeof (subif_addr));
subif_addr.sw_if_index = sw_if_index;
clib_memcpy (&subif_addr.addr, address, sizeof (*address));
@@ -735,7 +735,7 @@
}
/* Use subif pool index to select alias device. */
- memset (&ifr, 0, sizeof (ifr));
+ clib_memset (&ifr, 0, sizeof (ifr));
snprintf (ifr.ifr_name, sizeof (ifr.ifr_name),
"%s:%d", tm->tun_name, (int) (ap - tm->subifs));
@@ -835,7 +835,7 @@
return;
/* See if we already know about this subif */
- memset (&subif_addr, 0, sizeof (subif_addr));
+ clib_memset (&subif_addr, 0, sizeof (subif_addr));
subif_addr.sw_if_index = sw_if_index;
subif_addr.is_v6 = 1;
clib_memcpy (&subif_addr.addr, address, sizeof (*address));
@@ -852,8 +852,8 @@
}
/* Use subif pool index to select alias device. */
- memset (&ifr, 0, sizeof (ifr));
- memset (&ifr6, 0, sizeof (ifr6));
+ clib_memset (&ifr, 0, sizeof (ifr));
+ clib_memset (&ifr6, 0, sizeof (ifr6));
snprintf (ifr.ifr_name, sizeof (ifr.ifr_name),
"%s:%d", tm->tun_name, (int) (ap - tm->subifs));