Skip to content
Commit f9d4df18 authored by Fabio Baltieri's avatar Fabio Baltieri Committed by Fabio Baltieri
Browse files

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: default avatarMartin Jäger <martin@libre.solar>
Signed-off-by: default avatarFabio Baltieri <fabiobaltieri@google.com>
(cherry picked from commit 4856fd4c)
parent a042ba2b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment