X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf-text%2Ftypes%2Finteger.c;h=c08aa4bc24412b3573fd27af9b147ae703adb9dd;hp=ca0e5e6020b3ed0f3002ef410934bf196bb0b493;hb=0eb28a22a58435fe5bdea66e1a93f52275340c43;hpb=182e96a1ffde8437ec33c35143d073d57d8de52f diff --git a/formats/ctf-text/types/integer.c b/formats/ctf-text/types/integer.c index ca0e5e60..c08aa4bc 100644 --- a/formats/ctf-text/types/integer.c +++ b/formats/ctf-text/types/integer.c @@ -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; } }