From: Philippe Proulx Date: Wed, 27 Mar 2019 22:28:40 +0000 (-0400) Subject: `ctf` plugin: infer packet's total size from packet's content size X-Git-Tag: v2.0.0-pre5~115 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=ab03d3fb7c251b43d4ca15f723d6d6e1d82d66f0 `ctf` plugin: infer packet's total size from packet's content size If a packet context's `packet_size` field is missing, but the `content_size` field exists, use the packet's content size as the packet's total size. I believe this is valid CTF. Signed-off-by: Philippe Proulx --- diff --git a/plugins/ctf/common/metadata/ctf-meta-validate.c b/plugins/ctf/common/metadata/ctf-meta-validate.c index 322718e0..a84efa15 100644 --- a/plugins/ctf/common/metadata/ctf-meta-validate.c +++ b/plugins/ctf/common/metadata/ctf-meta-validate.c @@ -31,8 +31,6 @@ int validate_stream_class(struct ctf_stream_class *sc) int ret = 0; struct ctf_field_class_int *int_fc; struct ctf_field_class *fc; - bool has_total_size = false; - bool has_content_size = false; if (sc->is_translated) { goto end; @@ -131,8 +129,6 @@ int validate_stream_class(struct ctf_stream_class *sc) "`packet_size` member is signed."); goto invalid; } - - has_total_size = true; } fc = ctf_field_class_struct_borrow_member_field_class_by_name( @@ -152,15 +148,6 @@ int validate_stream_class(struct ctf_stream_class *sc) "`content_size` member is signed."); goto invalid; } - - has_content_size = true; - } - - if (has_content_size && !has_total_size) { - BT_LOGE_STR("Invalid packet context field class: " - "`content_size` member exists without " - "`packet_size` member."); - goto invalid; } fc = ctf_field_class_struct_borrow_member_field_class_by_name( diff --git a/plugins/ctf/common/msg-iter/msg-iter.c b/plugins/ctf/common/msg-iter/msg-iter.c index 7077d2e7..b7a0b9fd 100644 --- a/plugins/ctf/common/msg-iter/msg-iter.c +++ b/plugins/ctf/common/msg-iter/msg-iter.c @@ -969,14 +969,8 @@ enum bt_msg_iter_status set_current_packet_content_sizes( if (notit->cur_exp_packet_total_size == -1) { if (notit->cur_exp_packet_content_size != -1) { - BT_LOGW("Content size is set, but packet size is not: " - "notit-addr=%p, packet-context-field-addr=%p, " - "packet-size=%" PRId64 ", content-size=%" PRId64, - notit, notit->dscopes.stream_packet_context, - notit->cur_exp_packet_total_size, - notit->cur_exp_packet_content_size); - status = BT_MSG_ITER_STATUS_ERROR; - goto end; + notit->cur_exp_packet_total_size = + notit->cur_exp_packet_content_size; } } else { if (notit->cur_exp_packet_content_size == -1) { @@ -985,6 +979,9 @@ enum bt_msg_iter_status set_current_packet_content_sizes( } } + BT_ASSERT(notit->cur_exp_packet_total_size != -1); + BT_ASSERT(notit->cur_exp_packet_content_size != -1); + if (notit->cur_exp_packet_content_size > notit->cur_exp_packet_total_size) { BT_LOGW("Invalid packet or content size: " @@ -2942,7 +2939,6 @@ end: ret = set_current_packet_content_sizes(notit); if (ret) { status = BT_MSG_ITER_STATUS_ERROR; - goto end; } return status;