From 201cbb93bc0c7620d93364ec9bd5abbe335a2ecf Mon Sep 17 00:00:00 2001 From: Jan Philipp Tebernum Date: Sat, 28 Dec 2024 02:10:54 +0100 Subject: [PATCH] stlink: patch incorrect calloc argument order 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. --- .../misc/stlink/calloc-argument-order.patch | 25 +++++++++++++++++++ .../development/tools/misc/stlink/default.nix | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 pkgs/development/tools/misc/stlink/calloc-argument-order.patch diff --git a/pkgs/development/tools/misc/stlink/calloc-argument-order.patch b/pkgs/development/tools/misc/stlink/calloc-argument-order.patch new file mode 100644 index 00000000000000..2370736ad58501 --- /dev/null +++ b/pkgs/development/tools/misc/stlink/calloc-argument-order.patch @@ -0,0 +1,25 @@ +From 7781732b0e09104d19c1f8476f1851760f4fa5fa Mon Sep 17 00:00:00 2001 +From: Jan Philipp Tebernum +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 + diff --git a/pkgs/development/tools/misc/stlink/default.nix b/pkgs/development/tools/misc/stlink/default.nix index 27e5437d9517fc..af14b25f42b812 100644 --- a/pkgs/development/tools/misc/stlink/default.nix +++ b/pkgs/development/tools/misc/stlink/default.nix @@ -30,6 +30,8 @@ stdenv.mkDerivation rec { sha256 = "sha256-hlFI2xpZ4ldMcxZbg/T5/4JuFFdO9THLcU0DQKSFqrw="; }; + patches = [ ./calloc-argument-order.patch ]; + buildInputs = [ libusb1'