From 6b1cf1282d617f91e105916124a7b5c24dbe16bf Mon Sep 17 00:00:00 2001
From: znley <shanjiantao@loongson.cn>
Date: Wed, 14 Aug 2024 02:17:32 +0000
Subject: [PATCH] community/stlink: fix build with gcc14

---
 community/stlink/APKBUILD    |  2 ++
 community/stlink/gcc14.patch | 13 +++++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 community/stlink/gcc14.patch

diff --git a/community/stlink/APKBUILD b/community/stlink/APKBUILD
index 0f74c5d324dd..7ecd254971c5 100644
--- a/community/stlink/APKBUILD
+++ b/community/stlink/APKBUILD
@@ -11,6 +11,7 @@ makedepends="cmake libusb-dev samurai"
 options="!check" # upstream doesn't have automated tests
 subpackages="$pkgname-doc $pkgname-dev"
 source="$pkgname-$pkgver.tar.gz::https://github.com/stlink-org/stlink/archive/v$pkgver.tar.gz
+	gcc14.patch
 	"
 
 build() {
@@ -38,4 +39,5 @@ package() {
 
 sha512sums="
 49245a4b0aeb926dd71ec4260b707d900318fe68e3a36e2e5543587fefb4886a9ff0ff42e0e12a8e727a5d4e9c7b4ce13989ca4d963842dbf960065e5fa0c968  stlink-1.8.0.tar.gz
+f0374641756981c94d865d282cbe8009ccc9e9b41499501310f7442878e68b1984418428d13a7ea1f22312d5c928ec7bdb845d99a54a4264497a954859ad38cc  gcc14.patch
 "
diff --git a/community/stlink/gcc14.patch b/community/stlink/gcc14.patch
new file mode 100644
index 000000000000..c90de2ab28f0
--- /dev/null
+++ b/community/stlink/gcc14.patch
@@ -0,0 +1,13 @@
+diff --git a/src/stlink-lib/chipid.c b/src/stlink-lib/chipid.c
+index c115089..0a6a4e9 100644
+--- a/src/stlink-lib/chipid.c
++++ b/src/stlink-lib/chipid.c
+@@ -65,7 +65,7 @@ void process_chipfile(char *fname) {
+     return;
+   }
+ 
+-  ts = calloc(sizeof(struct stlink_chipid_params), 1);
++  ts = calloc(1, sizeof(struct stlink_chipid_params));
+ 
+   while (fgets(buf, sizeof(buf), fp) != NULL) {
+ 
-- 
GitLab