From fda0b800e18ea893311ab48d6b60edf3df0d122c Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 15 Apr 2025 11:29:18 +0200 Subject: [PATCH] chore: fix statix and deadnix warnings --- lib/netu.nix | 42 +++++++----------------------------------- lib/shift.nix | 2 +- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/lib/netu.nix b/lib/netu.nix index 47ad35f..154eb27 100644 --- a/lib/netu.nix +++ b/lib/netu.nix @@ -123,7 +123,7 @@ let delta' = typechecks.numeric function "delta" delta; mac' = typechecks.mac function "mac" mac; in - builders.mac (implementations.mac.add delta' mac'); + builders.mac (arithmetic.add delta' mac'); # diff :: mac -> mac -> integer # @@ -141,7 +141,7 @@ let minuend' = typechecks.mac function "minuend" minuend; subtrahend' = typechecks.mac function "subtrahend" subtrahend; in - implementations.mac.diff minuend' subtrahend'; + arithmetic.diff minuend' subtrahend'; # subtract :: (ip | mac | integer) -> mac -> mac # @@ -159,7 +159,7 @@ let delta' = typechecks.numeric function "delta" delta; mac' = typechecks.mac function "mac" mac; in - builders.mac (implementations.mac.subtract delta' mac'); + builders.mac (arithmetic.subtract delta' mac'); }; cidr = { @@ -531,10 +531,10 @@ let ap = liftA2 (a: a); # then_ :: parser a -> parser b -> parser b - then_ = liftA2 (a: b: b); + then_ = liftA2 (_: b: b); # empty :: parser a - empty = string: null; + empty = _: null; # alt :: parser a -> parser a -> parser a alt = @@ -684,8 +684,6 @@ let hextet = limit 4 hexadecimal; - hextet' = then_ colon hextet; - fromHextets = hextets: if builtins.length hextets != 8 then @@ -1076,7 +1074,7 @@ let diff = a: b: let - toIPv6 = coerce ({ ipv6.a = 0; }); + toIPv6 = coerce { ipv6.a = 0; }; result = (subtract b (toIPv6 a)).ipv6; max32 = bit.left 32 1 - 1; in @@ -1233,37 +1231,11 @@ let (bit.left 32 value.ipv6.c) value.ipv6.d ] - else if value ? ipv4 then - value.ipv4 - else if value ? mac then - value.mac else - value; + value.ipv4 or value.mac or value; }; implementations = { - ip = { - # add :: (ip | mac | integer) -> ip -> ip - add = arithmetic.add; - - # diff :: ip -> ip -> (ipv6 | integer) - diff = arithmetic.diff; - - # subtract :: (ip | mac | integer) -> ip -> ip - subtract = arithmetic.subtract; - }; - - mac = { - # add :: (ip | mac | integer) -> mac -> mac - add = arithmetic.add; - - # diff :: mac -> mac -> (ipv6 | integer) - diff = arithmetic.diff; - - # subtract :: (ip | mac | integer) -> mac -> mac - subtract = arithmetic.subtract; - }; - cidr = rec { # add :: (ip | mac | integer) -> cidr -> cidr add = diff --git a/lib/shift.nix b/lib/shift.nix index d686d0b..1e2576e 100644 --- a/lib/shift.nix +++ b/lib/shift.nix @@ -119,7 +119,7 @@ let negate = b < 0; mask = if a == 63 then intmax else (builtins.elemAt lut a) - 1; round_down = negate && (builtins.bitAnd mask b != 0); - result = (b / 2 / (builtins.elemAt lut (a - 1))); + result = b / 2 / (builtins.elemAt lut (a - 1)); in if round_down then result - 1 else result; in