Skip to content

Commit ee5c72e

Browse files
committed
Linux: fix supercan.h to comply to kernel UBSAN
1 parent 61aca71 commit ee5c72e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/supercan.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ struct sc_msg_can_rx {
304304
uint8_t flags;
305305
uint32_t can_id;
306306
uint32_t timestamp_us;
307-
uint8_t data[0];
307+
uint8_t data[];
308308
} SC_PACKED;
309309

310310
struct sc_msg_can_tx {
@@ -314,7 +314,7 @@ struct sc_msg_can_tx {
314314
uint8_t flags;
315315
uint32_t can_id;
316316
uint8_t track_id;
317-
uint8_t data[0];
317+
uint8_t data[];
318318
} SC_PACKED;
319319

320320
struct sc_msg_can_tx4 {
@@ -325,7 +325,7 @@ struct sc_msg_can_tx4 {
325325
uint32_t can_id;
326326
uint8_t track_id;
327327
uint8_t reserved[3];
328-
uint8_t data[0];
328+
uint8_t data[];
329329
} SC_PACKED;
330330

331331
struct sc_msg_can_txr {
@@ -337,7 +337,7 @@ struct sc_msg_can_txr {
337337
} SC_PACKED;
338338

339339
enum {
340-
sc_static_assert_sizeof_sc_msg_header_is_2 = sizeof(int[sizeof(struct sc_msg_header) == 2 ? 1 : -1]),
340+
sc_static_assert_sizeof_sc_msg_header_is_2 = sizeof(int[sizeof(struct sc_msg_header) == 2 ? 1 : -1]),
341341
sc_static_assert_sc_msg_req_is_a_multiple_of_4 = sizeof(int[(sizeof(struct sc_msg_req) & 0x3) == 0 ? 1 : -1]),
342342
sc_static_assert_sc_msg_error_is_a_multiple_of_4 = sizeof(int[(sizeof(struct sc_msg_error) & 0x3) == 0 ? 1 : -1]),
343343
sc_static_assert_sc_msg_hello_is_a_multiple_of_4 = sizeof(int[(sizeof(struct sc_msg_hello) & 0x3) == 0 ? 1 : -1]),
@@ -350,6 +350,7 @@ enum {
350350
sc_static_assert_sc_msg_can_status_is_a_multiple_of_4 = sizeof(int[(sizeof(struct sc_msg_can_status) & 0x3) == 0 ? 1 : -1]),
351351
sc_static_assert_sc_msg_can_error_is_a_multiple_of_4 = sizeof(int[(sizeof(struct sc_msg_can_error) & 0x3) == 0 ? 1 : -1]),
352352
sc_static_assert_sc_msg_can_tx4_is_a_multiple_of_4 = sizeof(int[(sizeof(struct sc_msg_can_tx4) & 0x3) == 0 ? 1 : -1]),
353+
sc_static_assert_sc_msg_can_tx4_size_is_12 = sizeof(int[sizeof(struct sc_msg_can_tx4) == 12 ? 1 : -1]),
353354
};
354355

355356
#ifdef __cplusplus

0 commit comments

Comments
 (0)