STMicroelectronics / OpenOCD

STMicroelectronics customized version of OpenOCD supporting STM32 MCUs and MPUs
Other
123 stars 32 forks source link

fix gcc 14.x builds #29

Open manujedi opened 3 months ago

manujedi commented 3 months ago

This should fix the warnings introduced with GCC 14 (?) -Werror=calloc-transposed-args and therefore breaks the builds

....
src/flash/nor/max32xxx.c: In function 'max32xxx_flash_bank_command':
src/flash/nor/max32xxx.c:90:30: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
   90 |         info = calloc(sizeof(struct max32xxx_flash_bank), 1);
      |                              ^~~~~~
src/flash/nor/max32xxx.c:90:30: note: earlier argument should specify number of elements, later size of each element
src/target/arc_jtag.c: In function 'arc_jtag_read_registers':
src/flash/nor/stm32f2x.c: In function 'stm32x_probe':
src/flash/nor/stellaris.c: In function 'stellaris_flash_bank_command':
src/target/arc_jtag.c:301:43: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  301 |         uint8_t *data_buf = calloc(sizeof(uint8_t), count * 4);
      |                                           ^~~~~~~
src/target/arc_jtag.c:301:43: note: earlier argument should specify number of elements, later size of each element
src/flash/nor/stldr_driver.c: In function 'stldr_parse':
src/flash/nor/stldr_driver.c:265:71: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  265 |                         struct stldr_section *section = calloc(sizeof(struct stldr_section), 1);
      |                                                                       ^~~~~~
src/flash/nor/stellaris.c:456:40: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  456 |         stellaris_info = calloc(sizeof(struct stellaris_flash_bank), 1);
  ...

Not sure if this PR is wanted. If there is a different fix from the openocd source simply close this PR. I already opened a PR but did not sign the Contribution License Agreement, sorry i did not know about it. Thanks!