histogram: add handling for datapoint == 0

__builtin_clzll(0) is technically undefined, but
returns 64 on all currently tested architectures,
which is the desired value.  So remove the
assert(datapoint != 0) and instead just set clz=64
for that case so that we aren't depending on
undefined behavior.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Ibb05f756e07f20a250d24f0c5adecc4dfbc5a056
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7939
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Jim Harris 2021-05-18 16:16:22 +00:00 committed by Tomasz Zawadzki
parent 7e9d5ae123
commit 0346e733e1

View File

@ -123,9 +123,7 @@ __spdk_histogram_data_get_bucket_range(struct spdk_histogram_data *h, uint64_t d
{
uint32_t clz, range;
assert(datapoint != 0);
clz = __builtin_clzll(datapoint);
clz = datapoint > 0 ? __builtin_clzll(datapoint) : 64;
if (clz <= SPDK_HISTOGRAM_BUCKET_LSB(h)) {
range = SPDK_HISTOGRAM_BUCKET_LSB(h) - clz;