Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
can: rework the table lookup code in can_dlc_to_bytes
Rework the can_dlc_to_bytes table lookup code in a way that allow the compiler to guess the resulting output and somehow fix the build warning: zephyr/drivers/can/can_nxp_s32_canxl.c:757:9: warning: '__builtin___memcpy_chk' forming offset [16, 71] is out of the bounds [0, 16] of object 'frame' with type 'struct can_frame' [-Warray-bounds] 757 | memcpy(frame->data, msg_data.data, can_dlc_to_bytes(frame->dlc)); where the compiler detects that frame->data is 8 bytes long but can_dlc_to_bytes could return more than that. Can be reproduced with: west build -p -b s32z270dc2_rtu1_r52 \ -T samples/net/sockets/can/sample.net.sockets.can.one_socket Suggested-by: Martin Jäger <martin@libre.solar> Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> (cherry picked from commit 4856fd4)
- Loading branch information