From ea0e619ec5a367076b752c24fa385af7aa82994a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sun, 11 Dec 2016 09:32:37 -0500 Subject: [PATCH] Rename bt_notification_packet_start to "begin" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- .../plugin/notification/notification.h | 4 +- .../plugin/notification/packet-internal.h | 2 +- .../babeltrace/plugin/notification/packet.h | 6 +-- lib/plugin-system/notification/packet.c | 42 ++++++++++++------- plugins/ctf/common/notif-iter/notif-iter.c | 2 +- plugins/ctf/fs/fs.c | 8 ++-- plugins/text/text.c | 2 +- plugins/writer/writer.c | 6 +-- 8 files changed, 43 insertions(+), 29 deletions(-) diff --git a/include/babeltrace/plugin/notification/notification.h b/include/babeltrace/plugin/notification/notification.h index 4636f229..34a185a0 100644 --- a/include/babeltrace/plugin/notification/notification.h +++ b/include/babeltrace/plugin/notification/notification.h @@ -48,8 +48,8 @@ enum bt_notification_type { /** Event delivery notification, see event.h */ BT_NOTIFICATION_TYPE_EVENT = 1, - /** Start of stream packet notification, see packet.h */ - BT_NOTIFICATION_TYPE_PACKET_START = 2, + /** Beginning of stream packet notification, see packet.h */ + BT_NOTIFICATION_TYPE_PACKET_BEGIN = 2, /** End of stream packet notification, see packet.h */ BT_NOTIFICATION_TYPE_PACKET_END = 3, diff --git a/include/babeltrace/plugin/notification/packet-internal.h b/include/babeltrace/plugin/notification/packet-internal.h index f1d1301e..e36bb6a1 100644 --- a/include/babeltrace/plugin/notification/packet-internal.h +++ b/include/babeltrace/plugin/notification/packet-internal.h @@ -30,7 +30,7 @@ #include #include -struct bt_notification_packet_start { +struct bt_notification_packet_begin { struct bt_notification parent; struct bt_ctf_packet *packet; }; diff --git a/include/babeltrace/plugin/notification/packet.h b/include/babeltrace/plugin/notification/packet.h index dd5bc909..c90b4c99 100644 --- a/include/babeltrace/plugin/notification/packet.h +++ b/include/babeltrace/plugin/notification/packet.h @@ -35,10 +35,10 @@ extern "C" { struct bt_ctf_packet; -/*** BT_NOTIFICATION_TYPE_PACKET_START ***/ -struct bt_notification *bt_notification_packet_start_create( +/*** BT_NOTIFICATION_TYPE_PACKET_BEGIN ***/ +struct bt_notification *bt_notification_packet_begin_create( struct bt_ctf_packet *packet); -struct bt_ctf_packet *bt_notification_packet_start_get_packet( +struct bt_ctf_packet *bt_notification_packet_begin_get_packet( struct bt_notification *notification); /*** BT_NOTIFICATION_TYPE_PACKET_END ***/ diff --git a/lib/plugin-system/notification/packet.c b/lib/plugin-system/notification/packet.c index 112f0f78..a57310f1 100644 --- a/lib/plugin-system/notification/packet.c +++ b/lib/plugin-system/notification/packet.c @@ -28,10 +28,10 @@ #include static -void bt_notification_packet_start_destroy(struct bt_object *obj) +void bt_notification_packet_begin_destroy(struct bt_object *obj) { - struct bt_notification_packet_start *notification = - (struct bt_notification_packet_start *) obj; + struct bt_notification_packet_begin *notification = + (struct bt_notification_packet_begin *) obj; BT_PUT(notification->packet); g_free(notification); @@ -47,33 +47,40 @@ void bt_notification_packet_end_destroy(struct bt_object *obj) g_free(notification); } -struct bt_notification *bt_notification_packet_start_create( +struct bt_notification *bt_notification_packet_begin_create( struct bt_ctf_packet *packet) { - struct bt_notification_packet_start *notification; + struct bt_notification_packet_begin *notification; if (!packet) { goto error; } - notification = g_new0(struct bt_notification_packet_start, 1); + notification = g_new0(struct bt_notification_packet_begin, 1); bt_notification_init(¬ification->parent, - BT_NOTIFICATION_TYPE_PACKET_START, - bt_notification_packet_start_destroy); + BT_NOTIFICATION_TYPE_PACKET_BEGIN, + bt_notification_packet_begin_destroy); notification->packet = bt_get(packet); return ¬ification->parent; error: return NULL; } -struct bt_ctf_packet *bt_notification_packet_start_get_packet( +struct bt_ctf_packet *bt_notification_packet_begin_get_packet( struct bt_notification *notification) { - struct bt_notification_packet_start *packet_start; + struct bt_ctf_packet *ret = NULL; + struct bt_notification_packet_begin *packet_begin; - packet_start = container_of(notification, - struct bt_notification_packet_start, parent); - return bt_get(packet_start->packet); + if (notification->type != BT_NOTIFICATION_TYPE_PACKET_BEGIN) { + goto end; + } + + packet_begin = container_of(notification, + struct bt_notification_packet_begin, parent); + ret = bt_get(packet_begin->packet); +end: + return ret; } struct bt_notification *bt_notification_packet_end_create( @@ -98,9 +105,16 @@ error: struct bt_ctf_packet *bt_notification_packet_end_get_packet( struct bt_notification *notification) { + struct bt_ctf_packet *ret = NULL; struct bt_notification_packet_end *packet_end; + if (notification->type != BT_NOTIFICATION_TYPE_PACKET_END) { + goto end; + } + packet_end = container_of(notification, struct bt_notification_packet_end, parent); - return bt_get(packet_end->packet); + ret = bt_get(packet_end->packet); +end: + return ret; } diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index 692ed6a9..106d2002 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -1896,7 +1896,7 @@ void notify_new_packet(struct bt_ctf_notif_iter *notit, return; } - ret = bt_notification_packet_start_create(notit->packet); + ret = bt_notification_packet_begin_create(notit->packet); if (!ret) { return; } diff --git a/plugins/ctf/fs/fs.c b/plugins/ctf/fs/fs.c index 71ae52b0..6b80d04a 100644 --- a/plugins/ctf/fs/fs.c +++ b/plugins/ctf/fs/fs.c @@ -144,11 +144,11 @@ struct bt_ctf_stream *internal_bt_notification_get_stream( bt_put(event); break; } - case BT_NOTIFICATION_TYPE_PACKET_START: + case BT_NOTIFICATION_TYPE_PACKET_BEGIN: { struct bt_ctf_packet *packet; - packet = bt_notification_packet_start_get_packet(notification); + packet = bt_notification_packet_begin_get_packet(notification); stream = bt_ctf_packet_get_stream(packet); bt_put(packet); break; @@ -428,7 +428,7 @@ bool compare_notifications(struct bt_notification *a, struct bt_notification *b, [BT_NOTIFICATION_TYPE_NEW_TRACE] = 0, [BT_NOTIFICATION_TYPE_NEW_STREAM_CLASS] = 1, [BT_NOTIFICATION_TYPE_NEW_EVENT_CLASS] = 2, - [BT_NOTIFICATION_TYPE_PACKET_START] = 3, + [BT_NOTIFICATION_TYPE_PACKET_BEGIN] = 3, [BT_NOTIFICATION_TYPE_PACKET_END] = 4, [BT_NOTIFICATION_TYPE_EVENT] = 5, [BT_NOTIFICATION_TYPE_END_OF_TRACE] = 6, @@ -457,7 +457,7 @@ bool compare_notifications(struct bt_notification *a, struct bt_notification *b, /* Notification types are equal, but not of type "event". */ switch (a_type) { - case BT_NOTIFICATION_TYPE_PACKET_START: + case BT_NOTIFICATION_TYPE_PACKET_BEGIN: case BT_NOTIFICATION_TYPE_PACKET_END: case BT_NOTIFICATION_TYPE_STREAM_END: { diff --git a/plugins/text/text.c b/plugins/text/text.c index 6781b1b6..2712dd68 100644 --- a/plugins/text/text.c +++ b/plugins/text/text.c @@ -119,7 +119,7 @@ enum bt_component_status handle_notification(struct text_component *text, } switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_START: + case BT_NOTIFICATION_TYPE_PACKET_BEGIN: puts(""); break; case BT_NOTIFICATION_TYPE_PACKET_END: diff --git a/plugins/writer/writer.c b/plugins/writer/writer.c index 525f0d57..ad99ed8a 100644 --- a/plugins/writer/writer.c +++ b/plugins/writer/writer.c @@ -126,10 +126,10 @@ enum bt_component_status handle_notification( } switch (bt_notification_get_type(notification)) { - case BT_NOTIFICATION_TYPE_PACKET_START: + case BT_NOTIFICATION_TYPE_PACKET_BEGIN: { struct bt_ctf_packet *packet = - bt_notification_packet_start_get_packet(notification); + bt_notification_packet_begin_get_packet(notification); if (!packet) { ret = BT_COMPONENT_STATUS_ERROR; @@ -143,7 +143,7 @@ enum bt_component_status handle_notification( case BT_NOTIFICATION_TYPE_PACKET_END: { struct bt_ctf_packet *packet = - bt_notification_packet_start_get_packet(notification); + bt_notification_packet_end_get_packet(notification); if (!packet) { ret = BT_COMPONENT_STATUS_ERROR; -- 2.34.1