summaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-12-13 11:43:13 -0500
committerDamjan Marion <dmarion.lists@gmail.com>2017-12-14 09:51:49 +0000
commit545d9eaeff62af74b6c1d2c27e6067f40685af93 (patch)
tree90ca2e1137e96bbbe45f219db1c2e9d817998612 /src/vppinfra
parent2f5eb0afa0893e94ed0115896d274de6f48cb93c (diff)
VPP-1032: clean up coverity warnings.
"This time, for sure..." Change-Id: Ie981003842d37c5eb6a0b2fe3abe974a93b86df8 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra')
-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)