From 5755d79b67ff3aea1f626561d3407f7da8eda1a6 Mon Sep 17 00:00:00 2001 From: Eugene Kabanov Date: Mon, 1 May 2023 00:46:15 +0300 Subject: [PATCH] Eliminate warnings (#383) * Eliminate warnings on Windows. * Deprecated toHex() in osnet. --- chronos/transports/osnet.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chronos/transports/osnet.nim b/chronos/transports/osnet.nim index 29b9562..02c0c64 100644 --- a/chronos/transports/osnet.nim +++ b/chronos/transports/osnet.nim @@ -16,7 +16,6 @@ else: {.push raises: [].} import std/algorithm -from std/strutils import toHex import ".."/osdefs import "."/ipnet export ipnet @@ -293,6 +292,9 @@ proc `$`*(ifa: InterfaceAddress): string = else: "Unknown" +proc hexDigit(x: uint8, lowercase: bool = false): char = + char(0x30'u8 + x + (uint32(7) and not((uint32(x) - 10) shr 8))) + proc `$`*(iface: NetworkInterface): string = ## Return string representation of network interface ``iface``. var res = $iface.ifIndex @@ -316,7 +318,8 @@ proc `$`*(iface: NetworkInterface): string = res.add(" ") if iface.maclen > 0: for i in 0 ..< iface.maclen: - res.add(toHex(iface.mac[i])) + res.add(hexDigit(iface.mac[i] shr 4)) + res.add(hexDigit(iface.mac[i] and 15)) if i < iface.maclen - 1: res.add(":") for item in iface.addresses: