Move to kernel style SPDX license identifiers
[babeltrace.git] / src / plugins / ctf / common / metadata / decoder-packetized-file-stream-to-buf.c
index 29986fabd8789f17f331288c5ccd3e3a961f2b74..ac067d2b250b048231997c501e6efd8d031f4a88 100644 (file)
@@ -1,21 +1,15 @@
 /*
- * Copyright 2016-2017 - Philippe Proulx <pproulx@efficios.com>
+ * SPDX-License-Identifier: MIT
  *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * Copyright 2016-2017 Philippe Proulx <pproulx@efficios.com>
  */
 
 #define BT_COMP_LOG_SELF_COMP self_comp
 #define BT_LOG_OUTPUT_LEVEL log_level
 #define BT_LOG_TAG "PLUGIN/CTF/META/DECODER-DECODE-PACKET"
-#include "plugins/comp-logging.h"
+#include "logging/comp-logging.h"
+
+#include "decoder-packetized-file-stream-to-buf.h"
 
 #include <stdio.h>
 #include <stdbool.h>
@@ -23,7 +17,7 @@
 #include <stdlib.h>
 #include <inttypes.h>
 #include "common/assert.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
 #include "compat/memstream.h"
 #include <babeltrace2/babeltrace.h>
 #include <glib.h>
 
 #define TSDL_MAGIC     0x75d11d57
 
-extern
-int yydebug;
-
 struct ctf_metadata_decoder {
        struct ctf_visitor_generate_ir *visitor;
-       uint8_t uuid[16];
+       bt_uuid_t uuid;
        bool is_uuid_set;
        int bo;
        struct ctf_metadata_decoder_config config;
@@ -49,7 +40,7 @@ struct ctf_metadata_decoder {
 
 struct packet_header {
        uint32_t magic;
-       uint8_t  uuid[16];
+       bt_uuid_t  uuid;
        uint32_t checksum;
        uint32_t content_size;
        uint32_t packet_size;
@@ -127,45 +118,15 @@ int decode_packet(FILE *in_fp, FILE *out_fp,
        /* Set expected trace UUID if not set; otherwise validate it */
        if (is_uuid_set) {
                if (!*is_uuid_set) {
-                       memcpy(uuid, header.uuid, sizeof(header.uuid));
+                       bt_uuid_copy(uuid, header.uuid);
                        *is_uuid_set = true;
                } else if (bt_uuid_compare(header.uuid, uuid)) {
                        BT_COMP_LOGE("Metadata UUID mismatch between packets of the same stream: "
-                               "packet-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", "
-                               "expected-uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\", "
+                               "packet-uuid=\"" BT_UUID_FMT "\", "
+                               "expected-uuid=\"" BT_UUID_FMT "\", "
                                "offset=%ld",
-                               (unsigned int) header.uuid[0],
-                               (unsigned int) header.uuid[1],
-                               (unsigned int) header.uuid[2],
-                               (unsigned int) header.uuid[3],
-                               (unsigned int) header.uuid[4],
-                               (unsigned int) header.uuid[5],
-                               (unsigned int) header.uuid[6],
-                               (unsigned int) header.uuid[7],
-                               (unsigned int) header.uuid[8],
-                               (unsigned int) header.uuid[9],
-                               (unsigned int) header.uuid[10],
-                               (unsigned int) header.uuid[11],
-                               (unsigned int) header.uuid[12],
-                               (unsigned int) header.uuid[13],
-                               (unsigned int) header.uuid[14],
-                               (unsigned int) header.uuid[15],
-                               (unsigned int) uuid[0],
-                               (unsigned int) uuid[1],
-                               (unsigned int) uuid[2],
-                               (unsigned int) uuid[3],
-                               (unsigned int) uuid[4],
-                               (unsigned int) uuid[5],
-                               (unsigned int) uuid[6],
-                               (unsigned int) uuid[7],
-                               (unsigned int) uuid[8],
-                               (unsigned int) uuid[9],
-                               (unsigned int) uuid[10],
-                               (unsigned int) uuid[11],
-                               (unsigned int) uuid[12],
-                               (unsigned int) uuid[13],
-                               (unsigned int) uuid[14],
-                               (unsigned int) uuid[15],
+                               BT_UUID_FMT_VALUES(header.uuid),
+                               BT_UUID_FMT_VALUES(uuid),
                                offset);
                        goto error;
                }
@@ -242,7 +203,7 @@ int ctf_metadata_decoder_packetized_file_stream_to_buf(FILE *fp,
        size_t packet_index = 0;
 
        out_fp = bt_open_memstream(buf, &size);
-       if (out_fp == NULL) {
+       if (!out_fp) {
                BT_COMP_LOGE("Cannot open memory stream: %s.",
                        strerror(errno));
                goto error;
This page took 0.024139 seconds and 4 git commands to generate.