zephyr/tests/lib
Andrew Boie 9926f947ab tests: ringbuffer: avoid unaligned mem access
Casting the rb_data character array to a u32_t can result
in an unaligned u32_t * pointer being passed to
ring_buf_item_put(), since rb_data is only byte-aligned.

Our Altera Max10 CPU build is not configured to detect
unaligned memory access and throw an exception, it is
instead rounding down the memory address
of the data pointer to the nearest 4-byte value, causing
the wrong data to be copied into the ring buffer.

It appears that in the C standard this is considered
Undefined Behavior so the approach this patch takes is
to fix the test, by ensuring that rb_data is aligned to
u32_t.

Fixes: #14869

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2019-04-09 19:59:46 -04:00
..
base64 license: cleanup: add SPDX Apache-2.0 license identifier 2019-04-07 08:45:22 -04:00
c_lib license: cleanup: add SPDX Apache-2.0 license identifier 2019-04-07 08:45:22 -04:00
json license: cleanup: add SPDX Apache-2.0 license identifier 2019-04-07 08:45:22 -04:00
mem_alloc license: cleanup: add SPDX Apache-2.0 license identifier 2019-04-07 08:45:22 -04:00
rbtree license: cleanup: add SPDX Apache-2.0 license identifier 2019-04-07 08:45:22 -04:00
ringbuffer tests: ringbuffer: avoid unaligned mem access 2019-04-09 19:59:46 -04:00
sprintf license: cleanup: add SPDX Apache-2.0 license identifier 2019-04-07 08:45:22 -04:00