lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 12 Dec 2019 22:54:14 +0100
From:   Jakub Wilk <jwilk@...lk.net>
To:     Stephen Hemminger <stephen@...workplumber.org>
Cc:     netdev@...r.kernel.org
Subject: [PATCH iproute2] ip: fix spelling of "Ki" IEC prefix

The symbol for binary prefix kibi is "Ki", with uppercase K.
In contrast, the symbol for decimal kilo is lowercase "k".

Signed-off-by: Jakub Wilk <jwilk@...lk.net>
---
 ip/ipaddress.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 964f14df..511ca6a8 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -551,7 +551,8 @@ static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
 
 void print_num(FILE *fp, unsigned int width, uint64_t count)
 {
-	const char *prefix = "kMGTPE";
+	const char *prefixes = "kMGTPE";
+	char prefix;
 	const unsigned int base = use_iec ? 1024 : 1000;
 	uint64_t powi = 1;
 	uint16_t powj = 1;
@@ -571,9 +572,9 @@ void print_num(FILE *fp, unsigned int width, uint64_t count)
 		if (count / base < powi)
 			break;
 
-		if (!prefix[1])
+		if (!prefixes[1])
 			break;
-		++prefix;
+		++prefixes;
 	}
 
 	/* try to guess a good number of digits for precision */
@@ -583,8 +584,11 @@ void print_num(FILE *fp, unsigned int width, uint64_t count)
 			break;
 	}
 
+	prefix = *prefixes;
+	if (use_iec && prefix == 'k')
+		prefix = 'K';
 	snprintf(buf, sizeof(buf), "%.*f%c%s", precision,
-		 (double) count / powi, *prefix, use_iec ? "i" : "");
+		 (double) count / powi, prefix, use_iec ? "i" : "");
 
 	fprintf(fp, "%-*s ", width, buf);
 }
-- 
2.24.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ