lib/ftl: fix scanbuild error about divided by zero.

We should add assert here to avoid be divided by zero,
that resolve this scanbuild error.

Change-Id: I12fa11cdbf0f608995f91759140408303e243357
Signed-off-by: yidong0635 <dongx.yi@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454539
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
yidong0635 2019-05-15 08:30:00 -04:00 committed by Jim Harris
parent 275f0c341c
commit 26683005dd

View File

@ -581,6 +581,7 @@ ftl_band_next_xfer_ppa(struct ftl_band *band, struct ftl_ppa ppa, size_t num_lbk
}
assert(band->num_chunks == _num_chunks);
#endif
assert(band->num_chunks != 0);
num_stripes = (num_lbks / dev->xfer_size) / band->num_chunks;
ppa.lbk += num_stripes * dev->xfer_size;
num_lbks -= num_stripes * dev->xfer_size * band->num_chunks;