zephyr/lib/utils
Christoph Winklhofer 061e345972 json: Fix calculation of object size
The calculation of the object size may be incorrect when the size of
a field is smaller than the struct alignment. When such a struct is
used in an array field, the decoded object contains wrong values.

The alignment influences the object size. For example the following
struct has a calculated object size of 8 bytes, however due to
alignment the real size of the struct is 12 bytes:

struct test_bool {
  bool b1; /* offset 0, size 1 */
           /* 3-byte padding */
  int i1;  /* offset 4, size 4 */
  bool b2; /* offset 8, size 1 */
           /* 3-byte padding */
};

This commit changes the object size calculation and computes the size
with the offset and size of the last field in the struct (rounded up
by the struct alignment).

Fixes: #85121
Signed-off-by: Christoph Winklhofer <cj.winklhofer@gmail.com>
2025-04-08 11:44:51 +02:00
..
base64.c
bitarray.c
CMakeLists.txt lib: utils: add consistent overhead byte stuffing 2025-03-11 05:36:49 +01:00
cobs.c lib: utils: add consistent overhead byte stuffing 2025-03-11 05:36:49 +01:00
dec.c
hex.c
json.c json: Fix calculation of object size 2025-04-08 11:44:51 +02:00
Kconfig ring_buffer: shrink size of struct ring_buf 2025-03-11 08:59:05 +01:00
notify.c
onoff.c
rb.c
ring_buffer.c ring_buffer: shrink size of struct ring_buf 2025-03-11 08:59:05 +01:00
timeutil.c
utf8.c
winstream.c