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 #960

Closed

Conversation

nerdCopter
Copy link
Member

@nerdCopter nerdCopter commented Jan 10, 2024

DRAFT - WIP

  • Fixes compiler warnings:
./src/main/pg/board.c:47:9: warning: 'strncpy' output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]
   47 |         strncpy(boardConfig->manufacturerId, TARGET_MANUFACTURER_IDENTIFIER, MAX_MANUFACTURER_ID_LENGTH);
./src/main/rx/crsf.c:132:90: warning: unused parameter 'currentTimeUs' [-Wunused-parameter]
  132 | static void handleCrsfLinkStatisticsFrame(const crsfLinkStatistics_t* statsPtr, timeUs_t currentTimeUs) {
./src/main/telemetry/ghst.c:85:17: warning: 'getGhstFrame' defined but not used [-Wunused-function]
   85 | STATIC_UNIT_TESTED uint8_t *getGhstFrame(){
./src/main/vcp_hal/usbd_desc.c: In function 'USBD_VCP_ConfigStrDescriptor':
./src/main/vcp_hal/usbd_desc.c:262:8: warning: this condition has identical branches [-Wduplicated-branches]
  262 |     if (speed == USBD_SPEED_HIGH) {
./src/main/vcp_hal/usbd_desc.c: In function 'USBD_VCP_InterfaceStrDescriptor':
./src/main/vcp_hal/usbd_desc.c:277:8: warning: this condition has identical branches [-Wduplicated-branches]
  277 |     if (speed == USBD_SPEED_HIGH) {
./lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c: In function 'USB_WritePacket':
./lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c:820:7: warning: 'packed' attribute ignored for type 'uint32_t *' {aka 'long unsigned int *'} [-Wattributes]
  820 |       USBx_DFIFO(ch_ep_num) = *((__packed uint32_t *)src);
./lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c: In function 'USB_ReadPacket':
./lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c:846:5: warning: 'packed' attribute ignored for type 'uint32_t *' {aka 'long unsigned int *'} [-Wattributes]
  846 |     *(__packed uint32_t *)dest = USBx_DFIFO(0);

ref: betaflight/betaflight#9228

  • The following need real-word testing. compiler no longer warns, but i'm unsure if such is stable: commit 42c113c5e (smartaudio FREQ mode OSD menu) & commit edd3d8b71 (beesign & spektrum functions)
  ./src/main/io/spektrum_vtx_control.c: In function 'convertSpektrumVtxPowerIndex':
./src/main/io/spektrum_vtx_control.c:115:46: warning: unused parameter 'sPower' [-Wunused-parameter]
  115 | uint8_t convertSpektrumVtxPowerIndex(uint8_t sPower) {
./src/main/cms/cms.c: In function 'cmsDrawMenuEntry':
./src/main/cms/cms.c:332:30: warning: cast between incompatible function types from 'CMSEntryFuncPtr' {aka 'long int (* const)(struct displayPort_s *, const void *)'} to 'char * (*)(void)' [-Wcast-function-type]
  332 |                 char *str = ((CMSMenuOptFuncPtr)p->func)();
      |                              ^
./src/main/drivers/beesign.c: In function 'beesignUpdate':
./src/main/drivers/beesign.c:611:9: warning: the address of 'checkBeesignSerialPort' will always evaluate as 'true' [-Waddress]
  611 |     if (checkBeesignSerialPort) {
      |         ^~~~~~~~~~~~~~~~~~~~~~
At top level:
./src/main/drivers/beesign.c:104:16: warning: 'beesignChkID' defined but not used [-Wunused-function]
  104 | static uint8_t beesignChkID(uint8_t id) {

@nerdCopter nerdCopter changed the title fix strncpy/truncate warning; fix unused CRSF timing stats fix compile warnings Jan 11, 2024
@nerdCopter

This comment was marked as outdated.

@nerdCopter nerdCopter force-pushed the 20210110_fix_compile_warnings branch from 2aae11c to edd3d8b Compare February 14, 2024 21:40
@nerdCopter
Copy link
Member Author

nerdCopter commented Feb 14, 2024

This entire PR needs real-world testing. please see original description, which may change.

  • OSD and Flight tested.
  • USB connectivity on F7's
  • USB Connectivity, flashing, and USB HID/MSC modes.
  • SmartAudio OSD Menu needs testing when FREQ-mode is used (not Band/Channel mode, but i suppose it should be tested as well)
  • Newbeedrone Beesign VTX and OSD menu (partially tested until my VTX goes wonky and fails to output randomly)

this is the last remaining warning for F7, but it is 3rd party library/driver.

./lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_uart.c: In function 'HAL_UART_Init':
./lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_uart.c:251:5: warning: this condition has identical branches [-Wduplicated-branches]
  251 |   if(huart->Init.HwFlowCtl != UART_HWCONTROL_NONE)
      |     ^

These warnings for HelioSring still exist:

./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 {
      |                ^~~~~~~~~~~
./lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_uart.c: In function 'HAL_UART_Init':
./lib/main/STM32F7/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_uart.c:251:5: warning: this condition has identical branches [-Wduplicated-branches]
  251 |   if(huart->Init.HwFlowCtl != UART_HWCONTROL_NONE)
      |     ^

@nerdCopter
Copy link
Member Author

nerdCopter commented Feb 19, 2024

  • test-hovered e824b756f on 2 quads. (One HDZero, one Analog).
  • tested, on bench, "POR FREQ" OSD Menu, no change in behavior, but uncertain that original behavior is correct. I sometimes lose transmission when FREQ mode is used rather than BAND/CHANNEL mode. (bith master and this commit SHA)

@nerdCopter nerdCopter force-pushed the 20210110_fix_compile_warnings branch from bd76047 to 61fcf99 Compare February 19, 2024 21:31
…based on board.h, but memcpy and removal of +1 from .h could work as well
@nerdCopter nerdCopter force-pushed the 20210110_fix_compile_warnings branch from 61fcf99 to 46520d7 Compare February 19, 2024 21:35
@nerdCopter
Copy link
Member Author

nerdCopter commented Feb 23, 2024

i feel i should close this and perform "Atomic" commits/fixes.
(the branch-name is dated wrong anyway)

@nerdCopter nerdCopter closed this Feb 23, 2024
@nerdCopter
Copy link
Member Author

nerdCopter commented Feb 26, 2024

re-openeing only to push a commit (cfcab4e48) that i flew for testing. flights had no known issues.

@nerdCopter nerdCopter reopened this Feb 26, 2024
@nerdCopter nerdCopter added the do-not-merge hold from merging until fixed or otherwise label Feb 26, 2024
@nerdCopter nerdCopter closed this Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge hold from merging until fixed or otherwise
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant