aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c14
-rw-r--r--src/vnet/dns/dns.c15
-rw-r--r--src/vppinfra/time.h10
3 files changed, 25 insertions, 14 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index e7382c29720..24b6fb06a3a 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -2137,6 +2137,7 @@ static void vl_api_memfd_segment_create_reply_t_handler
vam->client_index_invalid = 1;
+ /* Note: this closes memfd.fd */
retval = memfd_slave_init (&memfd);
if (retval)
clib_warning ("WARNING: segment map returned %d", retval);
@@ -2152,8 +2153,6 @@ static void vl_api_memfd_segment_create_reply_t_handler
vl_client_connect_to_vlib_no_map ("pvt",
"vpp_api_test(p)",
32 /* input_queue_length */ );
- if (close (my_fd) < 0)
- clib_unix_warning ("close memfd fd pivot");
vam->vl_input_queue = am->shmem_hdr->vl_input_queue;
vl_socket_client_enable_disable (&vam->socket_client_main,
@@ -20918,16 +20917,12 @@ api_app_namespace_add_del (vat_main_t * vam)
static int
api_memfd_segment_create (vat_main_t * vam)
{
+#if VPP_API_TEST_BUILTIN == 0
unformat_input_t *i = vam->input;
vl_api_memfd_segment_create_t *mp;
u64 size = 64 << 20;
int ret;
-#if VPP_API_TEST_BUILTIN == 1
- errmsg ("memfd_segment_create (builtin) not supported");
- return -99;
-#endif
-
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
if (unformat (i, "size %U", unformat_memory_size, &size))
@@ -20941,6 +20936,11 @@ api_memfd_segment_create (vat_main_t * vam)
S (mp);
W (ret);
return ret;
+
+#else
+ errmsg ("memfd_segment_create (builtin) not supported");
+ return -99;
+#endif
}
static int
diff --git a/src/vnet/dns/dns.c b/src/vnet/dns/dns.c
index 71ae7bb827c..9facb9b5640 100644
--- a/src/vnet/dns/dns.c
+++ b/src/vnet/dns/dns.c
@@ -690,6 +690,15 @@ delete_random_entry (dns_main_t * dm)
if (dm->is_enabled == 0)
return VNET_API_ERROR_NAME_RESOLUTION_NOT_ENABLED;
+ /*
+ * Silence spurious coverity warning. We know pool_elts >> 0, or
+ * we wouldn't be here...
+ */
+#ifdef __COVERITY__
+ if (pool_elts (dm->entries) == 0)
+ return VNET_API_ERROR_UNSPECIFIED;
+#endif
+
dns_cache_lock (dm);
limit = pool_elts (dm->entries);
start_index = random_u32 (&dm->random_seed) % limit;
@@ -936,8 +945,7 @@ vnet_dns_cname_indirection_nolock (dns_main_t * dm, u32 ep_index, u8 * reply)
pos += len;
len = *pos++;
}
- qp = (dns_query_t *) pos;
- pos += sizeof (*qp);
+ pos += sizeof (dns_query_t);
}
pos2 = pos;
/* expect a pointer chase here for a CNAME record */
@@ -1122,7 +1130,7 @@ vnet_dns_response_to_reply (u8 * response,
if ((pos[0] & 0xC0) == 0xC0)
{
curpos = pos + 2;
- break;
+ goto curpos_set;
}
pos += len;
len = *pos++;
@@ -1130,6 +1138,7 @@ vnet_dns_response_to_reply (u8 * response,
curpos = pos;
}
+ curpos_set:
rr = (dns_rr_t *) curpos;
switch (clib_net_to_host_u16 (rr->type))
diff --git a/src/vppinfra/time.h b/src/vppinfra/time.h
index 3fdc7d43ea8..288922d8a83 100644
--- a/src/vppinfra/time.h
+++ b/src/vppinfra/time.h
@@ -263,10 +263,12 @@ unix_usage_now (void)
always_inline void
unix_sleep (f64 dt)
{
- struct timespec t;
- t.tv_sec = dt;
- t.tv_nsec = 1e9 * dt;
- nanosleep (&t, 0);
+ struct timespec ts, tsrem;
+ ts.tv_sec = dt;
+ ts.tv_nsec = 1e9 * (dt - (f64) ts.tv_sec);
+
+ while (nanosleep (&ts, &tsrem) < 0)
+ ts = tsrem;
}
#else /* ! CLIB_UNIX */