From: Philippe Proulx Date: Sat, 8 Dec 2018 20:26:46 +0000 (-0500) Subject: Trace API: use status X-Git-Url: https://git.efficios.com/?a=commitdiff_plain;h=23578e82ecdd19a5209f0cac4288f85660142851;p=babeltrace.git Trace API: use status Signed-off-by: Philippe Proulx --- diff --git a/include/babeltrace/trace-ir/trace-const.h b/include/babeltrace/trace-ir/trace-const.h index 24f22394..42a80a79 100644 --- a/include/babeltrace/trace-ir/trace-const.h +++ b/include/babeltrace/trace-ir/trace-const.h @@ -39,6 +39,11 @@ extern "C" { #endif +enum bt_trace_status { + BT_TRACE_STATUS_OK = 0, + BT_TRACE_STATUS_NOMEM = -12, +}; + typedef void (* bt_trace_is_static_listener_func)(const bt_trace *trace, void *data); @@ -60,13 +65,14 @@ extern const bt_stream *bt_trace_borrow_stream_by_id_const( extern bt_bool bt_trace_is_static(const bt_trace *trace); -extern int bt_trace_add_is_static_listener(const bt_trace *trace, +extern enum bt_trace_status bt_trace_add_is_static_listener( + const bt_trace *trace, bt_trace_is_static_listener_func listener, bt_trace_listener_removed_func listener_removed, void *data, uint64_t *listener_id); -extern int bt_trace_remove_is_static_listener(const bt_trace *trace, - uint64_t listener_id); +extern enum bt_trace_status bt_trace_remove_is_static_listener( + const bt_trace *trace, uint64_t listener_id); extern void bt_trace_get_ref(const bt_trace *trace); diff --git a/include/babeltrace/trace-ir/trace.h b/include/babeltrace/trace-ir/trace.h index d00570e3..460c4b7d 100644 --- a/include/babeltrace/trace-ir/trace.h +++ b/include/babeltrace/trace-ir/trace.h @@ -30,6 +30,9 @@ /* For bt_bool, bt_trace, bt_trace_class, bt_stream */ #include +/* For enum bt_trace_status */ +#include + #include #ifdef __cplusplus @@ -40,7 +43,8 @@ extern bt_trace_class *bt_trace_borrow_class(bt_trace *trace); extern bt_trace *bt_trace_create(bt_trace_class *trace_class); -extern int bt_trace_set_name(bt_trace *trace, const char *name); +extern enum bt_trace_status bt_trace_set_name(bt_trace *trace, + const char *name); extern bt_stream *bt_trace_borrow_stream_by_index(bt_trace *trace, uint64_t index); @@ -48,7 +52,7 @@ extern bt_stream *bt_trace_borrow_stream_by_index(bt_trace *trace, extern bt_stream *bt_trace_borrow_stream_by_id(bt_trace *trace, uint64_t id); -extern int bt_trace_make_static(bt_trace *trace); +extern enum bt_trace_status bt_trace_make_static(bt_trace *trace); #ifdef __cplusplus } diff --git a/lib/trace-ir/trace.c b/lib/trace-ir/trace.c index 46380fd3..a46d8684 100644 --- a/lib/trace-ir/trace.c +++ b/lib/trace-ir/trace.c @@ -172,7 +172,7 @@ const char *bt_trace_get_name(const struct bt_trace *trace) return trace->name.value; } -int bt_trace_set_name(struct bt_trace *trace, const char *name) +enum bt_trace_status bt_trace_set_name(struct bt_trace *trace, const char *name) { BT_ASSERT_PRE_NON_NULL(trace, "Trace"); BT_ASSERT_PRE_NON_NULL(name, "Name"); @@ -180,7 +180,7 @@ int bt_trace_set_name(struct bt_trace *trace, const char *name) g_string_assign(trace->name.str, name); trace->name.value = trace->name.str->str; BT_LIB_LOGV("Set trace's name: %!+t", trace); - return 0; + return BT_TRACE_STATUS_OK; } uint64_t bt_trace_get_stream_count(const struct bt_trace *trace) @@ -237,7 +237,7 @@ bt_bool bt_trace_is_static(const struct bt_trace *trace) return (bt_bool) trace->is_static; } -int bt_trace_make_static(struct bt_trace *trace) +enum bt_trace_status bt_trace_make_static(struct bt_trace *trace) { uint64_t i; BT_ASSERT_PRE_NON_NULL(trace, "Trace"); @@ -256,10 +256,10 @@ int bt_trace_make_static(struct bt_trace *trace) } } - return 0; + return BT_TRACE_STATUS_OK; } -int bt_trace_add_is_static_listener( +enum bt_trace_status bt_trace_add_is_static_listener( const struct bt_trace *c_trace, bt_trace_is_static_listener_func listener, bt_trace_listener_removed_func listener_removed, void *data, @@ -304,7 +304,7 @@ int bt_trace_add_is_static_listener( BT_LIB_LOGV("Added \"trace is static\" listener: " "%![trace-]+t, listener-id=%" PRIu64, trace, i); - return 0; + return BT_TRACE_STATUS_OK; } BT_ASSERT_PRE_FUNC @@ -317,8 +317,8 @@ bool has_listener_id(const struct bt_trace *trace, uint64_t listener_id) listener_id))->func != NULL; } -int bt_trace_remove_is_static_listener(const struct bt_trace *c_trace, - uint64_t listener_id) +enum bt_trace_status bt_trace_remove_is_static_listener( + const struct bt_trace *c_trace, uint64_t listener_id) { struct bt_trace *trace = (void *) c_trace; struct bt_trace_is_static_listener_elem *elem; @@ -353,7 +353,7 @@ int bt_trace_remove_is_static_listener(const struct bt_trace *c_trace, BT_LIB_LOGV("Removed \"trace is static\" listener: " "%![trace-]+t, listener-id=%" PRIu64, trace, listener_id); - return 0; + return BT_TRACE_STATUS_OK; } BT_HIDDEN