X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Futils%2Fcounter%2Fcounter.c;h=5a6eadaf4ffec97c4cbcd9cfdb59a1439acd3164;hb=68b66a256a54d32992dfefeaad11eea88b7df234;hp=97bed28d4ab8abbc5c20496ab64462eaa39f3884;hpb=a5bc50e4b801a35b27b5c1ed9423cd543f54b52a;p=babeltrace.git diff --git a/plugins/utils/counter/counter.c b/plugins/utils/counter/counter.c index 97bed28d..5a6eadaf 100644 --- a/plugins/utils/counter/counter.c +++ b/plugins/utils/counter/counter.c @@ -20,11 +20,14 @@ * SOFTWARE. */ -#include -#include -#include +#define BT_LOG_TAG "PLUGIN-UTILS-COUNTER-FLT" +#include "logging.h" + +#include +#include +#include #include -#include +#include #include #include @@ -157,21 +160,27 @@ bt_self_component_status counter_init( counter->last_printed_total = -1ULL; counter->step = 10000; step = bt_value_map_borrow_entry_value_const(params, "step"); - if (step && bt_value_is_integer(step)) { - int64_t val; - - val = bt_value_integer_get(step); - if (val >= 0) { - counter->step = (uint64_t) val; + if (step) { + if (!bt_value_is_unsigned_integer(step)) { + BT_LOGE("`step` parameter: expecting an unsigned integer value: " + "type=%s", bt_common_value_type_string( + bt_value_get_type(step))); + goto error; } + + counter->step = bt_value_unsigned_integer_get(step); } hide_zero = bt_value_map_borrow_entry_value_const(params, "hide-zero"); - if (hide_zero && bt_value_is_bool(hide_zero)) { - bt_bool val; + if (hide_zero) { + if (!bt_value_is_bool(hide_zero)) { + BT_LOGE("`hide-zero` parameter: expecting a boolean value: " + "type=%s", bt_common_value_type_string( + bt_value_get_type(hide_zero))); + goto error; + } - val = bt_value_bool_get(hide_zero); - counter->hide_zero = (bool) val; + counter->hide_zero = (bool) bt_value_bool_get(hide_zero); } bt_self_component_set_data( @@ -181,6 +190,7 @@ bt_self_component_status counter_init( error: destroy_private_counter_data(counter); + ret = BT_SELF_COMPONENT_STATUS_ERROR; end: return ret;