Fix: overflowed return value
[babeltrace.git] / plugins / ctf / common / metadata / visitor-generate-ir.c
index cf7b4611e3e81ac80bfffd82dcbe8aa2736dde65..a2ced0cbed197266ecaddae2f885b24c5049f163 100644 (file)
@@ -1039,7 +1039,7 @@ enum bt_ctf_byte_order get_real_byte_order(struct ctx *ctx,
 static
 int is_align_valid(uint64_t align)
 {
-       return (align != 0) && !(align & (align - 1));
+       return (align != 0) && !(align & (align - 1ULL));
 }
 
 static
@@ -1650,7 +1650,7 @@ int visit_typealias(struct ctx *ctx, struct ctf_node *target,
        /* Do not allow typedef and typealias of untagged variants */
        if (bt_ctf_field_type_is_variant(type_decl)) {
                if (bt_ctf_field_type_variant_get_tag_name(type_decl)) {
-                       _BT_LOGE_NODE(node,
+                       _BT_LOGE_NODE(target,
                                "Type definition of untagged variant field type is not allowed.");
                        ret = -EPERM;
                        goto end;
@@ -1662,7 +1662,7 @@ int visit_typealias(struct ctx *ctx, struct ctf_node *target,
         * abstract or not (if it has an identifier). Check it here.
         */
        if (qdummy_field_name != 0) {
-               _BT_LOGE_NODE(node,
+               _BT_LOGE_NODE(target,
                        "Expecting empty identifier: id=\"%s\"",
                        g_quark_to_string(qdummy_field_name));
                ret = -EINVAL;
@@ -3634,6 +3634,7 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
                switch (stream_class_count) {
                case 0:
                        /* Create implicit stream class if there's none */
+                       stream_id = 0;
                        new_stream_class = create_reset_stream_class(ctx);
                        if (!new_stream_class) {
                                _BT_LOGE_NODE(node,
@@ -3642,7 +3643,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
                                goto error;
                        }
 
-                       ret = bt_ctf_stream_class_set_id(new_stream_class, 0);
+                       ret = bt_ctf_stream_class_set_id(new_stream_class,
+                               stream_id);
                        if (ret) {
                                _BT_LOGE_NODE(node,
                                        "Cannot set stream class's ID: "
@@ -3658,6 +3660,8 @@ int visit_event_decl(struct ctx *ctx, struct ctf_node *node)
                                goto error;
                        }
 
+                       *new_stream_id = stream_id;
+
                        /* Move reference to visitor's context */
                        g_hash_table_insert(ctx->stream_classes,
                                new_stream_id, new_stream_class);
This page took 0.024048 seconds and 4 git commands to generate.