Byte order is only set when packet-based metadata is found.
[babeltrace.git] / formats / ctf / ctf.c
index 4043055824b5e24fe253a7835ce9cc95fd989ab1..fd05c0ab2301c293db6aa9728e4d69ea0e1d49f2 100644 (file)
@@ -458,12 +458,13 @@ int packet_metadata(struct ctf_trace *td, FILE *fp)
        if (magic == TSDL_MAGIC) {
                ret = 1;
                td->byte_order = BYTE_ORDER;
+               CTF_TRACE_SET_FIELD(td, byte_order);
        } else if (magic == GUINT32_SWAP_LE_BE(TSDL_MAGIC)) {
                ret = 1;
                td->byte_order = (BYTE_ORDER == BIG_ENDIAN) ?
                                        LITTLE_ENDIAN : BIG_ENDIAN;
+               CTF_TRACE_SET_FIELD(td, byte_order);
        }
-       CTF_TRACE_SET_FIELD(td, byte_order);
 end:
        rewind(fp);
        return ret;
@@ -607,11 +608,12 @@ int ctf_open_trace_metadata_read(struct ctf_trace *td)
                goto end_stream;
        }
 
-       td->byte_order = BYTE_ORDER;
        if (packet_metadata(td, fp)) {
                ret = ctf_open_trace_metadata_stream_read(td, &fp, &buf);
                if (ret)
                        goto end_packet_read;
+       } else {
+               td->byte_order = BYTE_ORDER;
        }
 
        scanner = ctf_scanner_alloc(fp);
This page took 0.024901 seconds and 4 git commands to generate.