From 8a5d6f57a0a3e95aadae5816a6922052f31d49a8 Mon Sep 17 00:00:00 2001 From: Reno Dakota Date: Fri, 6 Dec 2024 05:48:34 +0000 Subject: [PATCH] libbladeRF: gcc-14 fixes fix build for gcc-14 > host/utilities/bladeRF-fsk/c/src/fir_filter.c:227:28: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument 227 | outbuf = calloc(sizeof(struct complex_sample), chunk_size); https://cache.nixos.org/log/hsg1v3cl1hk9ca77rgkng6n6dabz1bi3-libbladeRF-2.5.0.drv --- .../li/libbladeRF/gcc-14-calloc-fixes.diff | 26 +++++++++++++++++++ pkgs/by-name/li/libbladeRF/package.nix | 5 ++++ 2 files changed, 31 insertions(+) create mode 100644 pkgs/by-name/li/libbladeRF/gcc-14-calloc-fixes.diff diff --git a/pkgs/by-name/li/libbladeRF/gcc-14-calloc-fixes.diff b/pkgs/by-name/li/libbladeRF/gcc-14-calloc-fixes.diff new file mode 100644 index 0000000000000..ae11b26073b68 --- /dev/null +++ b/pkgs/by-name/li/libbladeRF/gcc-14-calloc-fixes.diff @@ -0,0 +1,26 @@ +diff --git a/host/utilities/bladeRF-fsk/c/src/fir_filter.c b/host/utilities/bladeRF-fsk/c/src/fir_filter.c +index 59f34f0..7def697 100644 +--- a/host/utilities/bladeRF-fsk/c/src/fir_filter.c ++++ b/host/utilities/bladeRF-fsk/c/src/fir_filter.c +@@ -213,18 +213,18 @@ int main(int argc, char *argv[]) + return EXIT_FAILURE; + } + +- inbuf = calloc(2*sizeof(int16_t), chunk_size); ++ inbuf = calloc(chunk_size, 2*sizeof(int16_t)); + if (!inbuf) { + perror("calloc"); + goto out; + } +- tempbuf = calloc(2*sizeof(int16_t), chunk_size); ++ tempbuf = calloc(chunk_size, 2*sizeof(int16_t)); + if (!tempbuf) { + perror("calloc"); + goto out; + } + +- outbuf = calloc(sizeof(struct complex_sample), chunk_size); ++ outbuf = calloc(chunk_size, sizeof(struct complex_sample)); + if (!outbuf) { + perror("calloc"); + goto out; diff --git a/pkgs/by-name/li/libbladeRF/package.nix b/pkgs/by-name/li/libbladeRF/package.nix index 77e72d22db6c7..4c05f76d13517 100644 --- a/pkgs/by-name/li/libbladeRF/package.nix +++ b/pkgs/by-name/li/libbladeRF/package.nix @@ -13,6 +13,11 @@ stdenv.mkDerivation rec { fetchSubmodules = true; }; + patches = [ + # https://github.com/Nuand/bladeRF/issues/994 + ./gcc-14-calloc-fixes.diff + ]; + nativeBuildInputs = [ cmake pkg-config git doxygen help2man ]; # ncurses used due to https://github.com/Nuand/bladeRF/blob/ab4fc672c8bab4f8be34e8917d3f241b1d52d0b8/host/utilities/bladeRF-cli/CMakeLists.txt#L208 buildInputs = [ tecla libusb1 ]