From: Jérémie Galarneau Date: Thu, 12 Sep 2019 14:02:06 +0000 (-0400) Subject: Clean-up: assert that get_count_order() returns a positive value X-Git-Tag: v2.12.0-rc1~396 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=46b4dda689c362426f3306e98b1e39759d387f6f Clean-up: assert that get_count_order() returns a positive value The callers of get_count_order() don't handle negative values correctly. However, those should not happen without a previous bug. Assert that its return value is >= 0. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/ust-metadata.c b/src/bin/lttng-sessiond/ust-metadata.c index 0eccac654..08199a16a 100644 --- a/src/bin/lttng-sessiond/ust-metadata.c +++ b/src/bin/lttng-sessiond/ust-metadata.c @@ -85,8 +85,10 @@ int get_count_order(unsigned int count) int order; order = fls(count) - 1; - if (count & (count - 1)) + if (count & (count - 1)) { order++; + } + assert(order >= 0); return order; }