json: make it 64-bit compatible

The struct json_obj_descr definition allocates only 2 bits for type
alignment. Instead of using them literally minus 1 to encode 1, 2, or 4,
let's store the alignment's shift value instead so that 1, 2, 4 or 8 can
be encoded with the same 2 bits to accommodate 64-bit builds.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
Nicolas Pitre 2019-05-17 17:17:33 -04:00 committed by Anas Nashif
commit 4323d381e7
2 changed files with 23 additions and 21 deletions

View file

@ -493,7 +493,7 @@ static ptrdiff_t get_elem_size(const struct json_obj_descr *descr)
for (i = 0; i < descr->object.sub_descr_len; i++) {
ptrdiff_t s = get_elem_size(&descr->object.sub_descr[i]);
total += ROUND_UP(s, descr->alignment + 1);
total += ROUND_UP(s, 1 << descr->align_shift);
}
return total;