X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Futils%2Ftrimmer%2Ftrimmer.c;h=54a1667070dc0937d7dcb59ebdc71437f537a0f5;hb=90157d89276ed1a569a2d4ffcfeed0b415817c12;hp=8ec1332fb0b09f2e9935df6c421d0d13448ff314;hpb=b9d103befd837c4411112257c2619ef8d68225dd;p=babeltrace.git diff --git a/plugins/utils/trimmer/trimmer.c b/plugins/utils/trimmer/trimmer.c index 8ec1332f..54a16670 100644 --- a/plugins/utils/trimmer/trimmer.c +++ b/plugins/utils/trimmer/trimmer.c @@ -26,13 +26,17 @@ * SOFTWARE. */ +#define BT_LOG_TAG "PLUGIN-UTILS-TRIMMER-FLT" +#include "logging.h" + +#include #include #include #include #include #include #include -#include +#include #include #include #include @@ -49,14 +53,7 @@ void destroy_trimmer_data(struct trimmer *trimmer) static struct trimmer *create_trimmer_data(void) { - struct trimmer *trimmer; - - trimmer = g_new0(struct trimmer, 1); - if (!trimmer) { - goto end; - } -end: - return trimmer; + return g_new0(struct trimmer, 1); } void finalize_trimmer(struct bt_private_component *component) @@ -84,7 +81,7 @@ void finalize_trimmer(struct bt_private_component *component) */ static int timestamp_from_arg(const char *arg, struct trimmer *trimmer, - struct trimmer_bound *result_bound, bool gmt) + struct trimmer_bound *result_bound, bt_bool gmt) { int ret; int64_t value; @@ -106,7 +103,7 @@ int timestamp_from_arg(const char *arg, struct trimmer *trimmer, time_t result; if (gmt) { - result = timegm(&tm); + result = bt_timegm(&tm); if (result < 0) { return -1; } @@ -152,7 +149,7 @@ int timestamp_from_arg(const char *arg, struct trimmer *trimmer, time_t result; if (gmt) { - result = timegm(&tm); + result = bt_timegm(&tm); if (result < 0) { return -1; } @@ -200,7 +197,7 @@ int timestamp_from_arg(const char *arg, struct trimmer *trimmer, }; if (gmt) { - value = timegm(&tm); + value = bt_timegm(&tm); if (value < 0) { return -1; } @@ -244,7 +241,7 @@ int timestamp_from_arg(const char *arg, struct trimmer *trimmer, time_t result; if (gmt) { - result = timegm(&tm); + result = bt_timegm(&tm); if (result < 0) { return -1; } @@ -292,7 +289,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, struct bt_value *params) { struct bt_value *value = NULL; - bool gmt = false; + bt_bool gmt = BT_FALSE; enum bt_component_status ret = BT_COMPONENT_STATUS_OK; assert(params); @@ -304,7 +301,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, value_ret = bt_value_bool_get(value, &gmt); if (value_ret) { ret = BT_COMPONENT_STATUS_INVALID; - printf_error("Failed to retrieve clock-gmt value. Expecting a boolean"); + BT_LOGE_STR("Failed to retrieve clock-gmt value. Expecting a boolean"); } } bt_put(value); @@ -321,7 +318,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, if (value_ret || timestamp_from_arg(str, trimmer, &trimmer->begin, gmt)) { ret = BT_COMPONENT_STATUS_INVALID; - printf_error("Failed to retrieve begin value. Expecting a timestamp string"); + BT_LOGE_STR("Failed to retrieve begin value. Expecting a timestamp string"); } } bt_put(value); @@ -338,14 +335,14 @@ enum bt_component_status init_from_params(struct trimmer *trimmer, if (value_ret || timestamp_from_arg(str, trimmer, &trimmer->end, gmt)) { ret = BT_COMPONENT_STATUS_INVALID; - printf_error("Failed to retrieve end value. Expecting a timestamp string"); + BT_LOGE_STR("Failed to retrieve end value. Expecting a timestamp string"); } } bt_put(value); end: if (trimmer->begin.set && trimmer->end.set) { if (trimmer->begin.value > trimmer->end.value) { - printf_error("Unexpected: time range begin value is above end value"); + BT_LOGE_STR("Unexpected: time range begin value is above end value"); ret = BT_COMPONENT_STATUS_INVALID; } } @@ -358,7 +355,6 @@ enum bt_component_status trimmer_component_init( { enum bt_component_status ret; struct trimmer *trimmer = create_trimmer_data(); - struct bt_private_port *priv_port = NULL; if (!trimmer) { ret = BT_COMPONENT_STATUS_NOMEM; @@ -366,16 +362,15 @@ enum bt_component_status trimmer_component_init( } /* Create input and output ports */ - priv_port = bt_private_component_filter_add_input_private_port( - component, "in", NULL); - if (!priv_port) { + ret = bt_private_component_filter_add_input_private_port( + component, "in", NULL, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { goto error; } - bt_put(priv_port); - priv_port = bt_private_component_filter_add_output_private_port( - component, "out", NULL); - if (!priv_port) { + ret = bt_private_component_filter_add_output_private_port( + component, "out", NULL, NULL); + if (ret != BT_COMPONENT_STATUS_OK) { goto error; } @@ -386,7 +381,6 @@ enum bt_component_status trimmer_component_init( ret = init_from_params(trimmer, params); end: - bt_put(priv_port); return ret; error: destroy_trimmer_data(trimmer);