Commit 09d8b2e3 authored by Petr Hodina's avatar Petr Hodina
Browse files

iotools: Fix werror and refactor definition

parent ed2bf86f
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
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';
+	}
+7 −5
Original line number Diff line number Diff line
@@ -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";
  };
}
})