From 09d8b2e359201af8a91f3d10354c4d9de1fd6781 Mon Sep 17 00:00:00 2001 From: Petr Hodina Date: Sat, 26 Apr 2025 10:47:59 +0200 Subject: [PATCH] iotools: Fix werror and refactor definition --- .../io/iotools/001-fix-werror-in-sprintf.patch | 13 +++++++++++++ pkgs/by-name/io/iotools/package.nix | 12 +++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 pkgs/by-name/io/iotools/001-fix-werror-in-sprintf.patch diff --git a/pkgs/by-name/io/iotools/001-fix-werror-in-sprintf.patch b/pkgs/by-name/io/iotools/001-fix-werror-in-sprintf.patch new file mode 100644 index 000000000000..58d6e01de398 --- /dev/null +++ b/pkgs/by-name/io/iotools/001-fix-werror-in-sprintf.patch @@ -0,0 +1,13 @@ +diff --git a/commands.c b/commands.c +index a83f1d5..b3f217a 100644 +--- a/commands.c ++++ b/commands.c +@@ -152,1 +152,7 @@ build_symlink_name(const char *path_to_bin, const struct cmd_info *cmd) +- snprintf(link_name, FILENAME_MAX, "%s/%s", path_to_bin, cmd->name); ++ int result = snprintf(link_name, FILENAME_MAX, "%s/%s", path_to_bin, cmd->name); ++ ++ if (result >= FILENAME_MAX) { ++ link_name[FILENAME_MAX - 1] = '\0'; ++ } else if (result < 0) { ++ link_name[0] = '\0'; ++ } diff --git a/pkgs/by-name/io/iotools/package.nix b/pkgs/by-name/io/iotools/package.nix index 7e71c12153bd..1e3a33d548b0 100644 --- a/pkgs/by-name/io/iotools/package.nix +++ b/pkgs/by-name/io/iotools/package.nix @@ -4,7 +4,7 @@ fetchFromGitHub, }: -stdenv.mkDerivation { +stdenv.mkDerivation (finalAttrs: { pname = "iotools"; version = "unstable-2017-12-11"; @@ -15,6 +15,8 @@ stdenv.mkDerivation { hash = "sha256-tlGXJn3n27mQDupMIVYDd86YaWazVwel/qs0QqCy1W8="; }; + patches = [ ./001-fix-werror-in-sprintf.patch ]; + makeFlags = [ "DEBUG=0" "STATIC=0" @@ -24,7 +26,7 @@ stdenv.mkDerivation { install -Dm755 iotools -t $out/bin ''; - meta = with lib; { + meta = { description = "Set of simple command line tools which allow access to hardware device registers"; longDescription = '' @@ -35,12 +37,12 @@ stdenv.mkDerivation { operations. ''; homepage = "https://github.com/adurbin/iotools"; - license = licenses.gpl2Only; - maintainers = with maintainers; [ felixsinger ]; + license = lib.licenses.gpl2Only; + maintainers = with lib.maintainers; [ felixsinger ]; platforms = [ "x86_64-linux" "i686-linux" ]; mainProgram = "iotools"; }; -} +})