From 488c76a8fc6ac68d72bbbaf97b71c9c2edd0627a Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Wed, 18 Sep 2019 02:14:59 -0400 Subject: [PATCH] Explanation comment for complex casadm logic. Different static analysis tools detects division by 0. To avoid reanalyzing this piece of code, explanation comment was added. Signed-off-by: Michal Mielewczyk --- casadm/statistics_view_text.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/casadm/statistics_view_text.c b/casadm/statistics_view_text.c index 07f1fc5..daf6130 100644 --- a/casadm/statistics_view_text.c +++ b/casadm/statistics_view_text.c @@ -882,6 +882,10 @@ static int adjust_column_widths(struct view_t *this, for (i = 0 ; i != w ; ++i) { int this_width = vector_get(&prv->col_w, i); + /* + * This condition is exactly the same as in above loop, where + * above_avg_cols is incremented. So there is no risk of division by 0. + */ if (this_width > avg_width) { int reduce_by = excess_width / above_avg_cols; vector_set(&prv->col_w, i, this_width - reduce_by);