OpenCyphal / libcanard

A compact implementation of the Cyphal/CAN protocol in C for high-integrity real-time embedded systems
http://opencyphal.org
MIT License
327 stars 192 forks source link

Fix wcast align warnings on ARM #197

Closed PonomarevDA closed 2 years ago

PonomarevDA commented 2 years ago

During building the canard.c with arm compiler with Wcast-align flag, few warnings appear. To reproduce these warnings, you may type the command below:

arm-none-eabi-gcc libcanard/canard.c -c -Wcast-align

It returns the following warnings:

libcanard/canard.c: In function 'txAVLPredicate':
libcanard/canard.c:327:45: warning: cast increases required alignment of target type [-Wcast-align]
  327 |     const CanardTxQueueItem* const other  = (const CanardTxQueueItem*) node;
      |                                             ^
libcanard/canard.c: In function 'rxSubscriptionPredicateOnPortID':
libcanard/canard.c:948:38: warning: cast increases required alignment of target type [-Wcast-align]
  948 |     const CanardPortID  other     = ((const CanardRxSubscription*) node)->port_id;
      |                                      ^
libcanard/canard.c: In function 'canardTxPeek':
libcanard/canard.c:1055:15: warning: cast increases required alignment of target type [-Wcast-align]
 1055 |         out = (const CanardTxQueueItem*) cavlFindExtremum(que->root, false);
      |               ^
libcanard/canard.c: In function 'canardRxAccept':
libcanard/canard.c:1099:21: warning: cast increases required alignment of target type [-Wcast-align]
 1099 |                     (CanardRxSubscription*) cavlSearch(&ins->rx_subscriptions[(size_t) model.transfer_kind],
      |                     ^
libcanard/canard.c: In function 'canardRxUnsubscribe':
libcanard/canard.c:1179:55: warning: cast increases required alignment of target type [-Wcast-align]
 1179 |         CanardRxSubscription* const sub             = (CanardRxSubscription*)
      |

This PR simply adds a new job with libcanard building for ARM to the github workflow that reproduces these warnings and an intermediate cast to (void*) to prevent these warnings.