diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-03 08:17:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-03 08:17:29 +0000 |
commit | 61c4ff8b2ddc3841050c17a5f87791653dbd2b7b (patch) | |
tree | e97b4f25c511372d73bdd96c389c5f468d99138a /util/types.c | |
parent | Adding upstream version 2.4. (diff) | |
download | nvme-cli-61c4ff8b2ddc3841050c17a5f87791653dbd2b7b.tar.xz nvme-cli-61c4ff8b2ddc3841050c17a5f87791653dbd2b7b.zip |
Adding upstream version 2.4+really2.3.upstream/2.4+really2.3
This reverts commit f42531334c05b7f49ae43c0a27e347a487fb2667.
Diffstat (limited to '')
-rw-r--r-- | util/types.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/util/types.c b/util/types.c index daef298..18ced77 100644 --- a/util/types.c +++ b/util/types.c @@ -46,31 +46,14 @@ uint64_t int48_to_long(__u8 *data) return result; } -static long double uint128_t_to_double(nvme_uint128_t data) -{ - int i; - long double result = 0; - - for (i = 0; i < sizeof(data.words) / sizeof(*data.words); i++) { - result *= 4294967296; - result += data.words[i]; - } - - return result; -} - -static char *__uint128_t_to_string(nvme_uint128_t val, bool l10n) +char *uint128_t_to_string(nvme_uint128_t val) { static char str[60]; int idx = 60; __u64 div, rem; - char *sep = NULL; - int i, len = 0; - - if (l10n) { - sep = localeconv()->thousands_sep; - len = strlen(sep); - } + char *sep = localeconv()->thousands_sep; + int len = sep ? strlen(sep) : 0; + int i; /* terminate at the end, and build up from the ones */ str[--idx] = '\0'; @@ -105,14 +88,17 @@ static char *__uint128_t_to_string(nvme_uint128_t val, bool l10n) return str + idx; } -char *uint128_t_to_string(nvme_uint128_t val) +static long double uint128_t_to_double(nvme_uint128_t data) { - return __uint128_t_to_string(val, false); -} + int i; + long double result = 0; -char *uint128_t_to_l10n_string(nvme_uint128_t val) -{ - return __uint128_t_to_string(val, true); + for (i = 0; i < sizeof(data.words) / sizeof(*data.words); i++) { + result *= 4294967296; + result += data.words[i]; + } + + return result; } char *uint128_t_to_si_string(nvme_uint128_t val, __u32 bytes_per_unit) |