diff --git a/pkgs/by-name/hi/hidrd/allocate-hex-map-with-the-trailing-null.patch b/pkgs/by-name/hi/hidrd/allocate-hex-map-with-the-trailing-null.patch new file mode 100644 index 000000000000..2d8de279ba48 --- /dev/null +++ b/pkgs/by-name/hi/hidrd/allocate-hex-map-with-the-trailing-null.patch @@ -0,0 +1,36 @@ +From 73a01e5e0091f5fbf452fd85ac3632f8c0171e65 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= +Date: Thu, 7 Aug 2025 17:50:48 +0200 +Subject: [PATCH] Allocate hex map with the trailing NULL +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Compilers usually warns or errors on such allocations. This would require +special compiler parameter or attribute to silence it. Unfortunately, it is +compiler specific, e.g. with gcc one could use "__attribute__ ((nonstring))" +or with C23 just "[[nonstring]]" or gcc parameter +"-Wno-error=unterminated-string-initialization". With other compilers +it's different. So do not over-complicate things and allocate it just one +more byte longer with the dummy NULL which should silence most of the +compilers. It's static allocation, just one byte, the overhead should be +negligible. + +Signed-off-by: Jaroslav Škarvada +--- + lib/util/hex.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/util/hex.c b/lib/util/hex.c +index 653e733..2292bd7 100644 +--- a/lib/util/hex.c ++++ b/lib/util/hex.c +@@ -84,7 +84,7 @@ hidrd_hex_buf_from_str(void *buf, + char * + hidrd_hex_buf_to_str(const void *buf, size_t size) + { +- static const char map[16] = "0123456789ABCDEF"; ++ static const char map[17] = "0123456789ABCDEF"; + const uint8_t *bbuf = (const uint8_t *)buf; + char *str; + char *p; diff --git a/pkgs/by-name/hi/hidrd/package.nix b/pkgs/by-name/hi/hidrd/package.nix index 2e5c80780a04..fe59be3d2be0 100644 --- a/pkgs/by-name/hi/hidrd/package.nix +++ b/pkgs/by-name/hi/hidrd/package.nix @@ -16,6 +16,13 @@ stdenv.mkDerivation { sha256 = "1rnhq6b0nrmphdig1qrpzpbpqlg3943gzpw0v7p5rwcdynb6bb94"; }; + patches = [ + # Fix build with gcc15 + # hex.c:87:35: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16 available) [-Werror=unterminated-string-initialization] + # https://github.com/DIGImend/hidrd/pull/33 + ./allocate-hex-map-with-the-trailing-null.patch + ]; + nativeBuildInputs = [ autoreconfHook ]; meta = {