Standardise spelling of debug info
[babeltrace.git] / formats / ctf-text / types / integer.c
index cc3a3551b2bc31074c4fd532c6414b456868db44..ca0e5e6020b3ed0f3002ef410934bf196bb0b493 100644 (file)
@@ -31,7 +31,7 @@
 #include <inttypes.h>
 #include <stdint.h>
 #include <babeltrace/bitfield.h>
-#include <babeltrace/trace-debuginfo.h>
+#include <babeltrace/trace-debug-info.h>
 
 int ctf_text_integer_write(struct bt_stream_pos *ppos, struct bt_definition *definition)
 {
@@ -101,10 +101,19 @@ int ctf_text_integer_write(struct bt_stream_pos *ppos, struct bt_definition *def
        {
                uint64_t v;
 
-               if (!integer_declaration->signedness)
+               if (!integer_declaration->signedness) {
                        v = integer_definition->value._unsigned;
-               else
+               } else {
                        v = (uint64_t) integer_definition->value._signed;
+                       if (integer_declaration->len < 64) {
+                               /* Round length to the nearest 3-bit */
+                               uint8_t rounded_len =
+                                       integer_declaration->len +
+                                       ((integer_declaration->len + 2) % 3);
+
+                               v &= ((uint64_t) 1 << rounded_len) - 1;
+                       }
+               }
 
                fprintf(pos->fp, "0%" PRIo64, v);
                break;
@@ -116,11 +125,14 @@ int ctf_text_integer_write(struct bt_stream_pos *ppos, struct bt_definition *def
                if (!integer_declaration->signedness) {
                        v = integer_definition->value._unsigned;
                } else {
-                       /* Round length to the nearest nibble */
-                       uint8_t rounded_len = ((integer_declaration->len + 3) & ~0x3);
-
                        v = (uint64_t) integer_definition->value._signed;
-                       v &= ((uint64_t) 1 << rounded_len) - 1;
+                       if (integer_declaration->len < 64) {
+                               /* Round length to the nearest nibble */
+                               uint8_t rounded_len =
+                                       ((integer_declaration->len + 3) & ~0x3);
+
+                               v &= ((uint64_t) 1 << rounded_len) - 1;
+                       }
                }
 
                fprintf(pos->fp, "0x%" PRIX64, v);
This page took 0.024519 seconds and 4 git commands to generate.