From: Stephen Hemminger <stephen@networkplumber.org>
To: Andre Muezerie <andremue@linux.microsoft.com>
Cc: bruce.richardson@intel.com, dev@dpdk.org,
sameh.gobriel@intel.com, vladimir.medvedkin@intel.com,
yipeng1.wang@intel.com
Subject: Re: [PATCH v2 1/3] eal: add function rte_size_to_str
Date: Tue, 11 Mar 2025 08:49:05 -0700 [thread overview]
Message-ID: <20250311084905.478375c1@hermes.local> (raw)
In-Reply-To: <1741707195-26880-1-git-send-email-andremue@linux.microsoft.com>
On Tue, 11 Mar 2025 08:33:13 -0700
Andre Muezerie <andremue@linux.microsoft.com> wrote:
> It's common to use %' in the printf format specifier to make large numbers
> more easily readable by having the thousands grouped. However, this
> grouping does not work on Windows. Therefore, a function is needed to make
> uint64_t numbers more easily readable. There are at least two tests that
> can benefit from this new function.
>
> Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
> ---
> lib/eal/common/eal_common_string_fns.c | 44 ++++++++++++++++++++++++++
> lib/eal/include/rte_common.h | 21 ++++++++++++
> 2 files changed, 65 insertions(+)
>
> diff --git a/lib/eal/common/eal_common_string_fns.c b/lib/eal/common/eal_common_string_fns.c
> index 9ca2045b18..b658d68eac 100644
> --- a/lib/eal/common/eal_common_string_fns.c
> +++ b/lib/eal/common/eal_common_string_fns.c
> @@ -4,6 +4,7 @@
>
> #include <ctype.h>
> #include <errno.h>
> +#include <inttypes.h>
> #include <stdio.h>
> #include <stdlib.h>
>
> @@ -87,6 +88,12 @@ rte_str_to_size(const char *str)
> endptr++; /* allow 1 space gap */
>
> switch (*endptr) {
> + case 'E': case 'e':
> + size *= 1024; /* fall-through */
> + case 'P': case 'p':
> + size *= 1024; /* fall-through */
> + case 'T': case 't':
> + size *= 1024; /* fall-through */
> case 'G': case 'g':
> size *= 1024; /* fall-through */
> case 'M': case 'm':
> @@ -98,3 +105,40 @@ rte_str_to_size(const char *str)
> }
> return size;
> }
> +
Is this right? Looks like existing code is not using correct multiple
The standard for communication is K = 1000 and the standard for storage is K = 1024.
That is why iproute2 has the use_iec flag.
https://en.wikipedia.org/wiki/Data-rate_units
next prev parent reply other threads:[~2025-03-11 15:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 20:03 [PATCH] hash_readwrite_autotest: fix printf parameters Andre Muezerie
2025-03-07 9:01 ` Bruce Richardson
2025-03-07 22:34 ` Andre Muezerie
2025-03-10 10:51 ` Bruce Richardson
2025-03-10 15:36 ` Stephen Hemminger
2025-03-11 14:39 ` Andre Muezerie
2025-03-11 15:01 ` Morten Brørup
2025-03-11 15:33 ` [PATCH v2 1/3] eal: add function rte_size_to_str Andre Muezerie
2025-03-11 15:33 ` [PATCH v2 2/3] hash_multiwriter_autotest: fix printf parameters Andre Muezerie
2025-03-11 15:33 ` [PATCH v2 3/3] hash_readwrite_autotest: " Andre Muezerie
2025-03-11 15:49 ` Stephen Hemminger [this message]
2025-03-11 15:51 ` [PATCH v2 1/3] eal: add function rte_size_to_str Bruce Richardson
2025-03-11 16:21 ` Morten Brørup
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=20250311084905.478375c1@hermes.local \
--to=stephen@networkplumber.org \
--cc=andremue@linux.microsoft.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=sameh.gobriel@intel.com \
--cc=vladimir.medvedkin@intel.com \
--cc=yipeng1.wang@intel.com \
/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).