summaryrefslogtreecommitdiffstats
path: root/util/types.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/types.c')
-rw-r--r--util/types.c40
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)