X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Futils%2Fcounter%2Fcounter.c;h=fea90c339b7e7f4194c073cf0f5d277561c3e7ad;hb=fdd3a2da18afef5ca32ba181a8b6ebbff173df02;hp=97bed28d4ab8abbc5c20496ab64462eaa39f3884;hpb=11cd69be12a8f694b9ddc9b8d8cc6936b7f51596;p=babeltrace.git diff --git a/plugins/utils/counter/counter.c b/plugins/utils/counter/counter.c index 97bed28d..fea90c33 100644 --- a/plugins/utils/counter/counter.c +++ b/plugins/utils/counter/counter.c @@ -20,6 +20,9 @@ * SOFTWARE. */ +#define BT_LOG_TAG "PLUGIN-UTILS-COUNTER-FLT" +#include "logging.h" + #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;