Fix: reversed logic in packet vs content size
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 27 Nov 2013 08:38:23 +0000 (03:38 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 21 Feb 2014 17:09:35 +0000 (12:09 -0500)
As described in CTF section 5.2

"If the packet size field is missing, the whole stream only contains a
single packet. If the content size field is missing, the packet is
filled (no padding). The content and packet sizes include all headers."

Here is the correct semantic:

* Content size and packet size are available:

  Packet is filled with data up to content size, and then with padding
  up to packet size.

* Content size available, no packet size field:

  The stream has a single packet. It is filled up to content size, and
  the rest is padding.

* Packet size available, no content size field:

  Packet filled completely, no padding.

Fixes #683

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c

index db6615b48dcaffe4c5b5b1f6925457e254d44ac8..687e360e1699e87bb1b8eba7b7077bf2d48fe388 100644 (file)
@@ -1486,28 +1486,28 @@ begin:
                        fprintf(stderr, "[error] Unable to read packet context: %s\n", strerror(-ret));
                        return ret;
                }
-               /* read content size from header */
-               len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
+               /* read packet size from header */
+               len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
                if (len_index >= 0) {
                        struct bt_definition *field;
 
                        field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
-                       packet_index.content_size = bt_get_unsigned_int(field);
+                       packet_index.packet_size = bt_get_unsigned_int(field);
                } else {
                        /* Use file size for packet size */
-                       packet_index.content_size = filesize * CHAR_BIT;
+                       packet_index.packet_size = filesize * CHAR_BIT;
                }
 
-               /* read packet size from header */
-               len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("packet_size"));
+               /* read content size from header */
+               len_index = bt_struct_declaration_lookup_field_index(file_stream->parent.stream_packet_context->declaration, g_quark_from_static_string("content_size"));
                if (len_index >= 0) {
                        struct bt_definition *field;
 
                        field = bt_struct_definition_get_field_from_index(file_stream->parent.stream_packet_context, len_index);
-                       packet_index.packet_size = bt_get_unsigned_int(field);
+                       packet_index.content_size = bt_get_unsigned_int(field);
                } else {
-                       /* Use content size if non-zero, else file size */
-                       packet_index.packet_size = packet_index.content_size ? : filesize * CHAR_BIT;
+                       /* Use packet size if non-zero, else file size */
+                       packet_index.content_size = packet_index.packet_size ? : filesize * CHAR_BIT;
                }
 
                /* read timestamp begin from header */
This page took 0.02645 seconds and 4 git commands to generate.