From: Jakub Wilk <jwilk@jwilk.net>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org
Subject: [PATCH iproute2] ip: fix spelling of "Ki" IEC prefix
Date: Thu, 12 Dec 2019 22:54:14 +0100 [thread overview]
Message-ID: <20191212215414.3655-1-jwilk@jwilk.net> (raw)
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@jwilk.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
next reply other threads:[~2019-12-12 22:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-12 21:54 Jakub Wilk [this message]
2019-12-14 23:48 ` [PATCH iproute2] ip: fix spelling of "Ki" IEC prefix Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191212215414.3655-1-jwilk@jwilk.net \
--to=jwilk@jwilk.net \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).