Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compile warnings - HelioSpring, Strix, Mode2Flux packed alignment of 4 same as uint32 #986

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nerdCopter
Copy link
Member

@nerdCopter nerdCopter commented Mar 4, 2024

fixes:

./src/main/drivers/accgyro/accgyro_imuf9001.c: In function 'imuf9001SendReceiveCommand':
./src/main/drivers/accgyro/accgyro_imuf9001.c:215:5: warning: converting a packed 'imufCommand_t' {aka 'struct imufCommand'} pointer (alignment 1) to a 'uint32_t' {aka 'long unsigned int'} pointer (alignment 4) may result in an unaligned pointer value [-Waddress-of-packed-member]
  215 |     command.crc     = getCrcImuf9001((uint32_t *)&command, 11);;
      |     ^~~~~~~
In file included from ./src/main/drivers/accgyro/accgyro_imuf9001.c:29:
./src/main/drivers/accgyro/accgyro_imuf9001.h:45:16: note: defined here
   45 | typedef struct imufCommand {
      |                ^~~~~~~~~~~
./src/main/drivers/accgyro/accgyro_imuf9001.c:221:17: warning: converting a packed 'imufCommand_t' {aka 'struct imufCommand'} pointer (alignment 1) to a 'uint32_t' {aka 'long unsigned int'} pointer (alignment 4) may result in an unaligned pointer value [-Waddress-of-packed-member]
  221 |                 crcCalc = getCrcImuf9001((uint32_t *)reply, 11);
      |                 ^~~~~~~
In file included from ./src/main/drivers/accgyro/accgyro_imuf9001.c:29:
./src/main/drivers/accgyro/accgyro_imuf9001.h:45:16: note: defined here
   45 | typedef struct imufCommand {
      |                ^~~~~~~~~~~
./src/main/drivers/accgyro/accgyro_imuf9001.c:227:25: warning: converting a packed 'imufCommand_t' {aka 'struct imufCommand'} pointer (alignment 1) to a 'uint32_t' {aka 'long unsigned int'} pointer (alignment 4) may result in an unaligned pointer value [-Waddress-of-packed-member]
  227 |                         command.crc     = getCrcImuf9001((uint32_t *)&command, 11);
      |                         ^~~~~~~
In file included from ./src/main/drivers/accgyro/accgyro_imuf9001.c:29:
./src/main/drivers/accgyro/accgyro_imuf9001.h:45:16: note: defined here
   45 | typedef struct imufCommand {
      |                ^~~~~~~~~~~
./src/main/drivers/accgyro/accgyro_imuf9001.c:240:29: warning: converting a packed 'imufCommand_t' {aka 'struct imufCommand'} pointer (alignment 1) to a 'uint32_t' {aka 'long unsigned int'} pointer (alignment 4) may result in an unaligned pointer value [-Waddress-of-packed-member]
  240 |                             crcCalc = getCrcImuf9001((uint32_t *)reply, 11);
      |                             ^~~~~~~
In file included from ./src/main/drivers/accgyro/accgyro_imuf9001.c:29:
./src/main/drivers/accgyro/accgyro_imuf9001.h:45:16: note: defined here
   45 | typedef struct imufCommand {
      |                ^~~~~~~~~~~

BUT, maybe we do NOT want this: https://cs50.stackexchange.com/questions/1337/what-does-attribute-packed-do 🤷‍♂️

What are the ramifications of not doing it on both sides? https://github.com/emuflight/imu-f/blob/master/src/board_comm/board_comm.h#L41-L55

@nerdCopter nerdCopter changed the title fix compile warnings - HelioSpring, Strix, Mode2Flux packed alignment of 4 same as unint32 fix compile warnings - HelioSpring, Strix, Mode2Flux packed alignment of 4 same as uint32 Mar 4, 2024
@nerdCopter nerdCopter force-pushed the 20240305_imuf9001_compile_warnings_fix branch from 867d491 to 71cbe24 Compare March 4, 2024 21:57
@nerdCopter nerdCopter marked this pull request as ready for review March 6, 2024 17:37
@nerdCopter nerdCopter marked this pull request as draft March 6, 2024 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant