aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-10-02 16:33:56 -0400
committerFlorin Coras <florin.coras@gmail.com>2018-10-02 21:36:12 +0000
commit819d5fdb39526386ee8fe4a8729f960e84443cbd (patch)
treef81e79c45024a20e04c817d5a0f44cd26b3d6ee8 /src/vppinfra
parentbf49590c07162be44b21d0e0440e7fb96b2746d5 (diff)
VPP-1440: clean up coverity warnings
Change-Id: Ic6823fb617ecae547a5f0e28b1e037848e40f682 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/cuckoo_template.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/vppinfra/cuckoo_template.c b/src/vppinfra/cuckoo_template.c
index 16537f92b3e..595bd1ca3bc 100644
--- a/src/vppinfra/cuckoo_template.c
+++ b/src/vppinfra/cuckoo_template.c
@@ -908,6 +908,7 @@ u8 *CV (format_cuckoo) (u8 * s, va_list * args)
uword free = 0;
uword used = 0;
uword use_count_total = 0;
+ float load_factor;
CVT (clib_cuckoo_bucket) * b;
/* *INDENT-OFF* */
clib_cuckoo_foreach_bucket (b, h, {
@@ -935,8 +936,11 @@ u8 *CV (format_cuckoo) (u8 * s, va_list * args)
s = format (s, "Used slots: %wu\n", used);
s = format (s, "Use count total: %wu\n", use_count_total);
s = format (s, "Free slots: %wu\n", free);
- s =
- format (s, "Load factor: %.2f\n", (float) (used) / (float) (free + used));
+ if (free + used != 0)
+ load_factor = ((float) used) / ((float) (free + used));
+ else
+ load_factor = 0.0;
+ s = format (s, "Load factor: %.2f\n", load_factor);
#if CLIB_CUCKOO_DEBUG_COUNTERS
s = format (s, "BFS attempts limited by max steps: %lld\n",
h->steps_exceeded);
@@ -968,7 +972,10 @@ float CV (clib_cuckoo_calculate_load_factor) (CVT (clib_cuckoo) * h)
}
});
/* *INDENT-ON* */
- return (float) nonfree / (float) all;
+ if (all)
+ return (float) nonfree / (float) all;
+ else
+ return 0.0;
}
/** @endcond */