X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf-text%2Ftypes%2Finteger.c;fp=formats%2Fctf-text%2Ftypes%2Finteger.c;h=82a1647b98446e0a45b8cd7b49ad65859b58ba1b;hp=ae08a5c1df0638614bfab40308175b2094e32bbf;hb=6d5b23425126d69529b461eb14bb34dedfa8e217;hpb=29435c3c1dfc364e2ac756e265194db3b2478729 diff --git a/formats/ctf-text/types/integer.c b/formats/ctf-text/types/integer.c index ae08a5c1..82a1647b 100644 --- a/formats/ctf-text/types/integer.c +++ b/formats/ctf-text/types/integer.c @@ -105,11 +105,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; } }