DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
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>,
	"Stephen Hemminger" <stephen@networkplumber.org>
Subject: RE: [PATCH v2 1/3] eal: add function rte_size_to_str
Date: Tue, 11 Mar 2025 17:21:14 +0100	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9FAED@smartserver.smartshare.dk> (raw)
In-Reply-To: <1741707195-26880-1-git-send-email-andremue@linux.microsoft.com>

> +	return snprintf(buf, buf_size, "%.*f%c%s", precision,
> +			(double)count / powi, *prefix, use_iec ? "i" : "");

I prefer a space between the number and the postfix (if a postfix is present), e.g. "1.23 M", so when followed by the unit, it becomes "1.23 Mbit/s" rather than "1.23M bit/s".

> +/**
> + * Converts the uint64_t value provided to a human-readable string.
> + * It null-terminates the string, truncating the data if needed.

Please add some examples showing the output formatting.
E.g.: "123 M", "12.3 M",
"12 M", " 12 M" or "12.0 M",
"1.00  ", "  1.00", or "     1", or something else?

> + *
> + * @param buf
> + *     Buffer to write the string to.
> + * @param buf_size
> + *     Size of the buffer.
> + * @param count
> + *     Number to convert.
> + * @param use_iec
> + *     If true, use IEC units (1024-based), otherwise use SI units
> (1000-based).
> + * @return
> + *     Number of characters written (not including the null-
> terminator),
> + *     or that would have been required when the buffer is too small.
> + */
> +int
> +rte_size_to_str(char *buf, int buf_size,
> +		uint64_t count, bool use_iec);
> +

      parent reply	other threads:[~2025-03-11 16:21 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   ` [PATCH v2 1/3] eal: add function rte_size_to_str Stephen Hemminger
2025-03-11 15:51     ` Bruce Richardson
2025-03-11 16:21   ` Morten Brørup [this message]

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=98CBD80474FA8B44BF855DF32C47DC35E9FAED@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=andremue@linux.microsoft.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=sameh.gobriel@intel.com \
    --cc=stephen@networkplumber.org \
    --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).