Skip to content

Commit 2bdc655

Browse files
authored
[x8h7_can] fix "-Wdeclaration-after-statement" warning. (#11)
This is caused by variable declarations after a block-of-code, i.e. variable declarations should be on top of any given block.
1 parent 32e4ba3 commit 2bdc655

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

recipes-kernel/kernel-modules/x8h7/x8h7_can.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ static void x8h7_can_hook(void *arg, x8h7_pkt_t *pkt)
274274
} else {
275275
struct sk_buff *skb;
276276
struct can_frame *frame;
277+
union x8h7_can_message x8h7_can_msg;
277278

278279
skb = alloc_can_skb(priv->net, &frame);
279280
if (!skb) {
@@ -283,7 +284,6 @@ static void x8h7_can_hook(void *arg, x8h7_pkt_t *pkt)
283284
}
284285

285286
/* Copy header from raw byte-stream onto union. */
286-
union x8h7_can_message x8h7_can_msg;
287287
memcpy(x8h7_can_msg.buf, pkt->data, X8H7_CAN_HEADER_SIZE);
288288

289289
/* Extract can_id and can_dlc. Note: x8h7_can_message uses the exact
@@ -545,8 +545,10 @@ static void x8h7_can_hw_tx(struct x8h7_can_priv *priv, struct can_frame *frame)
545545
DBG_PRINT("Send CAN frame to H7: id = %08X, len = %d, data = [%s ]\n", can_msg.field.id, can_msg.field.len, data_str);
546546
#endif
547547

548-
uint16_t const bytes_to_send = X8H7_CAN_HEADER_SIZE + x8h7_can_msg.field.len; /* Send 4-Byte ID, 1-Byte Length and the required number of data bytes. */
549-
x8h7_pkt_enq(priv->periph, X8H7_CAN_OC_SEND, bytes_to_send, x8h7_can_msg.buf);
548+
x8h7_pkt_enq(priv->periph,
549+
X8H7_CAN_OC_SEND,
550+
X8H7_CAN_HEADER_SIZE + x8h7_can_msg.field.len, /* Send 4-Byte ID, 1-Byte Length and the required number of data bytes. */
551+
x8h7_can_msg.buf);
550552
x8h7_pkt_send();
551553
}
552554

0 commit comments

Comments
 (0)