Skip to content

Commit

Permalink
fix(stlink): patch the incorrect calloc argument order
Browse files Browse the repository at this point in the history
With the update to GCC 14, stlink v1.8.0 is broken, as GCC 14 enforces
the correct argument order of calloc. This commit adds a little patch to
resolve that issue for now. This patch should be removed and stlink
updated to v1.8.1 as soon as that version gets released.
  • Loading branch information
jpteb committed Dec 28, 2024
1 parent 19fadd1 commit f2e95a7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pkgs/development/tools/misc/stlink/calloc-argument-order.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 7781732b0e09104d19c1f8476f1851760f4fa5fa Mon Sep 17 00:00:00 2001
From: Jan Philipp Tebernum <[email protected]>
Date: Sat, 28 Dec 2024 01:59:20 +0100
Subject: [PATCH] fix: correct argument order for calloc

---
src/stlink-lib/chipid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

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) {

--
2.47.0

2 changes: 2 additions & 0 deletions pkgs/development/tools/misc/stlink/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ stdenv.mkDerivation rec {
sha256 = "sha256-hlFI2xpZ4ldMcxZbg/T5/4JuFFdO9THLcU0DQKSFqrw=";
};

patches = [ ./calloc-argument-order.patch ];

buildInputs =
[
libusb1'
Expand Down

0 comments on commit f2e95a7

Please sign in to comment.