Skip to content

Commit

Permalink
json: Fix 64-bit support
Browse files Browse the repository at this point in the history
This patch fixes encoding arrays of objects on 64-bit targets.

Fixes #36696

Signed-off-by: Markus Fuchs <[email protected]>
  • Loading branch information
mrfuchs authored and carlescufi committed Jun 29, 2023
1 parent b311c53 commit 8757c71
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/os/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,10 @@ static ptrdiff_t get_elem_size(const struct json_obj_descr *descr)
size_t i;

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, 1 << descr->align_shift);
total += get_elem_size(&descr->object.sub_descr[i]);
}

return total;
return ROUND_UP(total, 1 << descr->align_shift);
}
default:
return -EINVAL;
Expand Down

0 comments on commit 8757c71

Please sign in to comment.