aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vppinfra/maplog.c1
-rw-r--r--src/vppinfra/random.c16
2 files changed, 12 insertions, 5 deletions
diff --git a/src/vppinfra/maplog.c b/src/vppinfra/maplog.c
index 158361b0bda..deb07aa9b76 100644
--- a/src/vppinfra/maplog.c
+++ b/src/vppinfra/maplog.c
@@ -394,6 +394,7 @@ clib_maplog_process (char *file_basename, void *fp_arg)
goto out;
}
(void) close (fd);
+ fd = -1;
file_size_in_bytes = h->file_size_in_records
* h->record_size_in_cachelines * CLIB_CACHE_LINE_BYTES;
diff --git a/src/vppinfra/random.c b/src/vppinfra/random.c
index e54a3bc8c7c..ea89f0a1618 100644
--- a/src/vppinfra/random.c
+++ b/src/vppinfra/random.c
@@ -63,20 +63,26 @@ u32 standalone_random_default_seed = 1;
f64
clib_chisquare (u64 * values)
{
- int i;
+ u32 i, len;
f64 d, delta_d, actual_frequency, expected_frequency;
u64 n_observations = 0;
- ASSERT (vec_len (values));
+ len = vec_len (values);
+ /*
+ * Shut up coverity. Return a huge number which should always exceed
+ * the X2 critical value.
+ */
+ if (len == 0)
+ return (f64) 1e70;
- for (i = 0; i < vec_len (values); i++)
+ for (i = 0; i < len; i++)
n_observations += values[i];
- expected_frequency = (1.0 / (f64) vec_len (values)) * (f64) n_observations;
+ expected_frequency = (1.0 / (f64) len) * (f64) n_observations;
d = 0.0;
- for (i = 0; i < vec_len (values); i++)
+ for (i = 0; i < len; i++)
{
actual_frequency = ((f64) values[i]);
delta_d = ((actual_frequency - expected_frequency)