zephyr/tests/lib
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
..
acpi
c_lib everywhere: Replace diagnostic pragmas with TOOLCHAIN_* macros 2025-03-20 21:57:47 +01:00
cbprintf_fp
cbprintf_package tests: lib: cbprintf_package: Extend test coverage 2024-11-01 09:56:03 -05:00
cmsis_dsp tests: unskip some tests 2025-03-28 21:52:13 +01:00
cmsis_nn tests: cmsis-nn: update tests for v7.0.0 2025-02-13 06:39:17 +01:00
cobs tests: utils: lib: cobs tests 2025-03-11 05:36:49 +01:00
cpp kscan: drop kscan and any reference 2025-03-13 16:56:26 +00:00
devicetree device: introduce struct device_ops 2025-03-10 21:32:40 +01:00
fdtable
gui/lvgl tests: Introduce greyscale-related tests modifications 2025-03-12 14:05:14 +00:00
hash_function
hash_map
heap boards: rename qemu_xtensa to qemu_xtensa/dc233c 2024-10-02 09:58:36 +02:00
heap_align tests/lib/heap_align: improve test some more 2025-03-17 02:21:27 +01:00
json json: Fix calculation of object size 2025-04-08 11:44:51 +02:00
linear_range
lockfree tests: remove misnamed platforms from platform_exclude 2024-09-16 10:07:51 +02:00
math/interpolation tests: fix various test ids and use existing scheme 2025-04-07 11:22:36 +02:00
mem_alloc everywhere: Use correct macro for gcc-specific warnings 2025-03-20 21:57:47 +01:00
mem_blocks
mem_blocks_stats
mpsc_pbuf boards native_posix: Remove twister support 2025-03-07 19:16:14 +01:00
multi_heap tests: lib: multi_heap: fix stack overflow 2025-03-12 07:15:12 +01:00
net_buf tests: lib: net_buf: move network buffer tests to tests/lib/net_buf 2024-09-07 11:19:05 -05:00
newlib
notify
onoff
p4workq kernel: rename 'dumb' scheduler and simply call it 'simple' 2025-03-15 00:34:58 +01:00
ringbuffer ring_buffer: shrink size of struct ring_buf 2025-03-11 08:59:05 +01:00
shared_multi_heap
smf tests: lib: smf: Add missing equals 2025-01-20 16:27:10 +01:00
sprintf everywhere: Use correct macro for gcc-specific warnings 2025-03-20 21:57:47 +01:00
spsc_pbuf
sys_util
time boards native_posix: Remove twister support 2025-03-07 19:16:14 +01:00