`ctf` plugin: infer packet's total size from packet's content size
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 27 Mar 2019 22:28:40 +0000 (18:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:39 +0000 (18:19 -0400)
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 <eeppeliteloop@gmail.com>
plugins/ctf/common/metadata/ctf-meta-validate.c
plugins/ctf/common/msg-iter/msg-iter.c

index 322718e08a442feaa58ed6e37fb5a364ace72e27..a84efa15d1c9b2504e2c7baf8c39cc5b1db1ae50 100644 (file)
@@ -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(
index 7077d2e7360cb4739a3129508bd06aae49dd0ac6..b7a0b9fd47b8f2003cb3dd6cb9363e76195acef2 100644 (file)
@@ -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;
This page took 0.026913 seconds and 4 git commands to generate.