Fix: undefined bit shift operation when printing octal numbers
[babeltrace.git] / formats / ctf-text / types / integer.c
index ca0e5e6020b3ed0f3002ef410934bf196bb0b493..c08aa4bc24412b3573fd27af9b147ae703adb9dd 100644 (file)
@@ -106,11 +106,12 @@ int ctf_text_integer_write(struct bt_stream_pos *ppos, struct bt_definition *def
                } 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);
+                               size_t len = integer_declaration->len;
+                               size_t rounded_len;
 
+                               assert(len != 0);
+                               /* Round length to the nearest 3-bit */
+                               rounded_len = (((len - 1) / 3) + 1) * 3;
                                v &= ((uint64_t) 1 << rounded_len) - 1;
                        }
                }
This page took 0.025148 seconds and 4 git commands to generate.