From: Jérémie Galarneau Date: Wed, 10 Jun 2020 17:00:16 +0000 (-0400) Subject: Clean-up: coding style fixes in dynamic-buffer.c X-Git-Tag: v2.13.0-rc1~621 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=12aacdf65716d710aca1bf81a782a2ab7cef8492;p=lttng-tools.git Clean-up: coding style fixes in dynamic-buffer.c 1) An empty line is expected before any statement after a scope is closed 2) Variables should be marked const where possible. Signed-off-by: Jérémie Galarneau Change-Id: I803e62fd759348416faae0bc108cacc726ce64da --- diff --git a/src/common/dynamic-buffer.c b/src/common/dynamic-buffer.c index b6544e62b..26d318dcd 100644 --- a/src/common/dynamic-buffer.c +++ b/src/common/dynamic-buffer.c @@ -17,10 +17,9 @@ static size_t round_to_power_of_2(size_t val) { - int order; size_t rounded; + const int order = utils_get_count_order_u64(val); - order = utils_get_count_order_u64(val); assert(order >= 0); rounded = (1ULL << order); assert(rounded >= val); @@ -135,6 +134,7 @@ int lttng_dynamic_buffer_set_size(struct lttng_dynamic_buffer *buffer, * size _before_ making such calls. */ } + buffer->size = new_size; end: return ret; @@ -168,6 +168,7 @@ int lttng_dynamic_buffer_set_capacity(struct lttng_dynamic_buffer *buffer, ret = -1; goto end; } + buffer->data = new_buf; buffer->_capacity = new_capacity; end: @@ -181,6 +182,7 @@ void lttng_dynamic_buffer_reset(struct lttng_dynamic_buffer *buffer) if (!buffer) { return; } + buffer->size = 0; buffer->_capacity = 0; free(buffer->data); @@ -193,5 +195,6 @@ size_t lttng_dynamic_buffer_get_capacity_left( if (!buffer) { return 0; } + return buffer->_capacity - buffer->size; }