Commit 0346e733 authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ibb05f756e07f20a250d24f0c5adecc4dfbc5a056
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7939


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Community-CI: Mellanox Build Bot
parent 7e9d5ae1
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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;