Fix: bitfield: shift undefined/implementation defined behaviors
[babeltrace.git] / plugins / text / pretty / print.c
index 914ae4c2d1b3b93745741974ce7c376e7dca3b58..e779bcc204500c7292612985e44bcfcdf2886aa7 100644 (file)
@@ -416,7 +416,7 @@ int print_event_header(struct pretty_component *pretty,
                        } else if (dom_print) {
                                g_string_append(pretty->string, ":");
                        }
-                       value = bt_value_integer_get(vpid_value);
+                       value = bt_value_signed_integer_get(vpid_value);
                        g_string_append_printf(pretty->string,
                                "(%" PRId64 ")", value);
                        dom_print = 1;
@@ -546,10 +546,10 @@ int print_integer(struct pretty_component *pretty,
 
                len = bt_field_class_integer_get_field_value_range(int_fc);
                g_string_append(pretty->string, "0b");
-               v.u = _bt_piecewise_lshift(v.u, 64 - len);
+               _bt_safe_lshift(v.u, 64 - len);
                for (bitnr = 0; bitnr < len; bitnr++) {
                        g_string_append_printf(pretty->string, "%u", (v.u & (1ULL << 63)) ? 1 : 0);
-                       v.u = _bt_piecewise_lshift(v.u, 1);
+                       _bt_safe_lshift(v.u, 1);
                }
                break;
        }
@@ -775,7 +775,7 @@ int print_struct_field(struct pretty_component *pretty,
        int ret = 0;
        const char *field_name;
        const bt_field *field = NULL;
-       const bt_field_class *field_class = NULL;;
+       const bt_field_class_structure_member *member;
 
        field = bt_field_structure_borrow_member_field_by_index_const(_struct, i);
        if (!field) {
@@ -783,8 +783,9 @@ int print_struct_field(struct pretty_component *pretty,
                goto end;
        }
 
-       bt_field_class_structure_borrow_member_by_index_const(struct_class, i,
-               &field_name, &field_class);
+       member = bt_field_class_structure_borrow_member_by_index_const(
+               struct_class, i);
+       field_name = bt_field_class_structure_member_get_name(member);
 
        if (filter_fields && !filter_field_name(pretty, field_name,
                                filter_fields, filter_array_len)) {
@@ -821,11 +822,9 @@ int print_struct(struct pretty_component *pretty,
                ret = -1;
                goto end;
        }
+
        nr_fields = bt_field_class_structure_get_member_count(struct_class);
-       if (nr_fields < 0) {
-               ret = -1;
-               goto end;
-       }
+
        g_string_append(pretty->string, "{");
        pretty->depth++;
        nr_printed_fields = 0;
@@ -923,11 +922,6 @@ int print_sequence(struct pretty_component *pretty,
        uint64_t i;
 
        len = bt_field_array_get_length(seq);
-       if (len < 0) {
-               ret = -1;
-               goto end;
-       }
-
        g_string_append(pretty->string, "[");
 
        pretty->depth++;
This page took 0.03075 seconds and 4 git commands to generate.