Skip to content

Commit a2f1183

Browse files
Shawn Landdenmarckleinebudde
authored andcommitted
can.h: make padding given by gcc explicit
The current definition of struct can_frame has a 16-byte size, with 8-byte alignment, but the 3 bytes of padding are not explicit like the similar 2 bytes of padding of struct canfd_frame. Make it explicit so it is easier to read. Signed-off-by: Shawn Landden <shawn@churchofgit.com> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 239fb79 commit a2f1183

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎Documentation/networking/can.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ solution for a couple of reasons:
268268
struct can_frame {
269269
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
270270
__u8 can_dlc; /* frame payload length in byte (0 .. 8) */
271+
__u8 __pad; /* padding */
272+
__u8 __res0; /* reserved / padding */
273+
__u8 __res1; /* reserved / padding */
271274
__u8 data[8] __attribute__((aligned(8)));
272275
};
273276

‎include/uapi/linux/can.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,17 @@ typedef __u32 can_err_mask_t;
9595
* @can_dlc: frame payload length in byte (0 .. 8) aka data length code
9696
* N.B. the DLC field from ISO 11898-1 Chapter 8.4.2.3 has a 1:1
9797
* mapping of the 'data length code' to the real payload length
98+
* @__pad: padding
99+
* @__res0: reserved / padding
100+
* @__res1: reserved / padding
98101
* @data: CAN frame payload (up to 8 byte)
99102
*/
100103
struct can_frame {
101104
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
102105
__u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
106+
__u8 __pad; /* padding */
107+
__u8 __res0; /* reserved / padding */
108+
__u8 __res1; /* reserved / padding */
103109
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
104110
};
105111

0 commit comments

Comments
 (0)