Просмотр исходного кода

openocd: fix issues with gcc 15.x

Waldemar Brodkorb 1 неделя назад
Родитель
Сommit
01503364e7

+ 1 - 1
package/openocd/Makefile

@@ -11,7 +11,7 @@ PKG_DESCR:=		jtag flash and debugging utility
 PKG_SECTION:=		dev/tools
 HOST_BUILDDEP:=		libusb-host
 PKG_URL:=		http://openocd.org/
-PKG_SITES:=		${MASTER_SITE_SOURCEFORGE:=openocd/}
+PKG_SITES:=		https://sourceforge.net/projects/openocd/files/openocd/$(PKG_VERSION)/
 
 DISTFILES:=		${PKG_NAME}-${PKG_VERSION}.tar.bz2
 

+ 11 - 0
package/openocd/patches/patch-src_flash_nor_ambiqmicro_c

@@ -0,0 +1,11 @@
+--- openocd-0.12.0.orig/src/flash/nor/ambiqmicro.c	2022-09-18 15:46:15.000000000 +0200
++++ openocd-0.12.0/src/flash/nor/ambiqmicro.c	2026-05-05 04:06:15.239041473 +0200
+@@ -124,7 +124,7 @@ FLASH_BANK_COMMAND_HANDLER(ambiqmicro_fl
+ 	if (CMD_ARGC < 6)
+ 		return ERROR_COMMAND_SYNTAX_ERROR;
+ 
+-	ambiqmicro_info = calloc(sizeof(struct ambiqmicro_flash_bank), 1);
++	ambiqmicro_info = calloc(1, sizeof(struct ambiqmicro_flash_bank));
+ 
+ 	bank->driver_priv = ambiqmicro_info;
+ 

+ 20 - 0
package/openocd/patches/patch-src_flash_nor_kinetis_c

@@ -0,0 +1,20 @@
+--- openocd-0.12.0.orig/src/flash/nor/kinetis.c	2022-09-18 15:46:15.000000000 +0200
++++ openocd-0.12.0/src/flash/nor/kinetis.c	2026-05-05 04:06:55.991251342 +0200
+@@ -898,7 +898,7 @@ FLASH_BANK_COMMAND_HANDLER(kinetis_flash
+ 	k_chip = kinetis_get_chip(target);
+ 
+ 	if (!k_chip) {
+-		k_chip = calloc(sizeof(struct kinetis_chip), 1);
++		k_chip = calloc(1, sizeof(struct kinetis_chip));
+ 		if (!k_chip) {
+ 			LOG_ERROR("No memory");
+ 			return ERROR_FAIL;
+@@ -999,7 +999,7 @@ static int kinetis_create_missing_banks(
+ 					 bank_idx - k_chip->num_pflash_blocks);
+ 		}
+ 
+-		bank = calloc(sizeof(struct flash_bank), 1);
++		bank = calloc(1, sizeof(struct flash_bank));
+ 		if (!bank)
+ 			return ERROR_FAIL;
+ 

+ 11 - 0
package/openocd/patches/patch-src_flash_nor_max32xxx_c

@@ -0,0 +1,11 @@
+--- openocd-0.12.0.orig/src/flash/nor/max32xxx.c	2022-09-18 15:46:15.000000000 +0200
++++ openocd-0.12.0/src/flash/nor/max32xxx.c	2026-05-05 04:07:54.815542519 +0200
+@@ -87,7 +87,7 @@ FLASH_BANK_COMMAND_HANDLER(max32xxx_flas
+ 		return ERROR_FLASH_BANK_INVALID;
+ 	}
+ 
+-	info = calloc(sizeof(struct max32xxx_flash_bank), 1);
++	info = calloc(1, sizeof(struct max32xxx_flash_bank));
+ 	COMMAND_PARSE_NUMBER(uint, CMD_ARGV[2], info->flash_size);
+ 	COMMAND_PARSE_NUMBER(uint, CMD_ARGV[6], info->flc_base);
+ 	COMMAND_PARSE_NUMBER(uint, CMD_ARGV[7], info->sector_size);

+ 11 - 0
package/openocd/patches/patch-src_flash_nor_msp432_c

@@ -0,0 +1,11 @@
+--- openocd-0.12.0.orig/src/flash/nor/msp432.c	2022-09-18 15:46:15.000000000 +0200
++++ openocd-0.12.0/src/flash/nor/msp432.c	2026-05-05 04:08:59.363847645 +0200
+@@ -937,7 +937,7 @@ static int msp432_probe(struct flash_ban
+ 
+ 	if (is_main && MSP432P4 == msp432_bank->family_type) {
+ 		/* Create the info flash bank needed by MSP432P4 variants */
+-		struct flash_bank *info = calloc(sizeof(struct flash_bank), 1);
++		struct flash_bank *info = calloc(1, sizeof(struct flash_bank));
+ 		if (!info)
+ 			return ERROR_FAIL;
+ 

+ 11 - 0
package/openocd/patches/patch-src_flash_nor_stellaris_c

@@ -0,0 +1,11 @@
+--- openocd-0.12.0.orig/src/flash/nor/stellaris.c	2022-09-18 15:46:15.000000000 +0200
++++ openocd-0.12.0/src/flash/nor/stellaris.c	2026-05-05 04:09:32.323998209 +0200
+@@ -453,7 +453,7 @@ FLASH_BANK_COMMAND_HANDLER(stellaris_fla
+ 	if (CMD_ARGC < 6)
+ 		return ERROR_COMMAND_SYNTAX_ERROR;
+ 
+-	stellaris_info = calloc(sizeof(struct stellaris_flash_bank), 1);
++	stellaris_info = calloc(1, sizeof(struct stellaris_flash_bank));
+ 	bank->base = 0x0;
+ 	bank->driver_priv = stellaris_info;
+ 

+ 11 - 0
package/openocd/patches/patch-src_flash_nor_stm32f2x_c

@@ -0,0 +1,11 @@
+--- openocd-0.12.0.orig/src/flash/nor/stm32f2x.c	2022-09-18 15:46:15.000000000 +0200
++++ openocd-0.12.0/src/flash/nor/stm32f2x.c	2026-05-05 04:18:36.362135854 +0200
+@@ -1018,7 +1018,7 @@ static int stm32x_probe(struct flash_ban
+ 		assert(num_sectors > 0);
+ 
+ 		bank->num_sectors = num_sectors;
+-		bank->sectors = calloc(sizeof(struct flash_sector), num_sectors);
++		bank->sectors = calloc(num_sectors, sizeof(struct flash_sector));
+ 
+ 		if (stm32x_otp_is_f7(bank))
+ 			bank->size = STM32F7_OTP_SIZE;

+ 11 - 0
package/openocd/patches/patch-src_jtag_drivers_ulink_c

@@ -0,0 +1,11 @@
+--- openocd-0.12.0.orig/src/jtag/drivers/ulink.c	2022-09-18 15:46:16.000000000 +0200
++++ openocd-0.12.0/src/jtag/drivers/ulink.c	2026-05-05 03:57:01.919144261 +0200
+@@ -1473,7 +1473,7 @@ static int ulink_queue_scan(struct ulink
+ 
+ 	/* Allocate TDO buffer if required */
+ 	if ((type == SCAN_IN) || (type == SCAN_IO)) {
+-		tdo_buffer_start = calloc(sizeof(uint8_t), scan_size_bytes);
++		tdo_buffer_start = calloc(scan_size_bytes, sizeof(uint8_t));
+ 
+ 		if (!tdo_buffer_start)
+ 			return ERROR_FAIL;

+ 20 - 0
package/openocd/patches/patch-src_target_arc_jtag_c

@@ -0,0 +1,20 @@
+--- openocd-0.12.0.orig/src/target/arc_jtag.c	2022-09-18 15:46:16.000000000 +0200
++++ openocd-0.12.0/src/target/arc_jtag.c	2026-05-05 04:28:58.644688551 +0200
+@@ -298,7 +298,7 @@ static int arc_jtag_read_registers(struc
+ 			ARC_JTAG_READ_FROM_CORE_REG : ARC_JTAG_READ_FROM_AUX_REG);
+ 	arc_jtag_enque_set_transaction(jtag_info, transaction, TAP_DRPAUSE);
+ 
+-	uint8_t *data_buf = calloc(sizeof(uint8_t), count * 4);
++	uint8_t *data_buf = calloc(count * 4, sizeof(uint8_t));
+ 
+ 	arc_jtag_enque_register_rw(jtag_info, addr, data_buf, NULL, count);
+ 
+@@ -498,7 +498,7 @@ int arc_jtag_read_memory(struct arc_jtag
+ 	if (!count)
+ 		return ERROR_OK;
+ 
+-	data_buf = calloc(sizeof(uint8_t), count * 4);
++	data_buf = calloc(count * 4, sizeof(uint8_t));
+ 	arc_jtag_enque_reset_transaction(jtag_info);
+ 
+ 	/* We are reading from memory. */

+ 20 - 0
package/openocd/patches/patch-src_target_nds32_c

@@ -0,0 +1,20 @@
+--- openocd-0.12.0.orig/src/target/nds32.c	2022-09-18 15:46:16.000000000 +0200
++++ openocd-0.12.0/src/target/nds32.c	2026-05-05 04:19:26.238309939 +0200
+@@ -381,7 +381,7 @@ static const struct reg_arch_type nds32_
+ static struct reg_cache *nds32_build_reg_cache(struct target *target,
+ 		struct nds32 *nds32)
+ {
+-	struct reg_cache *cache = calloc(sizeof(struct reg_cache), 1);
++	struct reg_cache *cache = calloc(1, sizeof(struct reg_cache));
+ 	struct reg *reg_list = calloc(TOTAL_REG_NUM, sizeof(struct reg));
+ 	struct nds32_reg *reg_arch_info = calloc(TOTAL_REG_NUM, sizeof(struct nds32_reg));
+ 	int i;
+@@ -409,7 +409,7 @@ static struct reg_cache *nds32_build_reg
+ 		reg_list[i].size = nds32_reg_size(i);
+ 		reg_list[i].arch_info = &reg_arch_info[i];
+ 
+-		reg_list[i].reg_data_type = calloc(sizeof(struct reg_data_type), 1);
++		reg_list[i].reg_data_type = calloc(1, sizeof(struct reg_data_type));
+ 
+ 		if (reg_arch_info[i].num >= FD0 && reg_arch_info[i].num <= FD31) {
+ 			reg_list[i].value = reg_arch_info[i].value;