From f9ea0c1d9cfe6b57a556060b7d9374a64457d183 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sun, 27 Oct 2019 15:52:37 +0100 Subject: cli,output: fix truncated array output when == 10 elements The extra character size was only being applied when > 10 elements, leaving the == 10 case out of it, so the output was being truncated. Fix it, by using a more generic way to computing how many extra characters we need in the size. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/151 --- cli/mmcli-output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cli/mmcli-output.c') diff --git a/cli/mmcli-output.c b/cli/mmcli-output.c index 338e6589..c72af513 100644 --- a/cli/mmcli-output.c +++ b/cli/mmcli-output.c @@ -964,8 +964,10 @@ dump_output_keyvalue (void) n = multiple->values ? g_strv_length (multiple->values) : 0; if (n > 0) { + guint aux = n; + key_length += ((strlen (KEY_ARRAY_VALUE_SUFFIX)) + 3); - if (n > 10) + while ((aux /= 10) > 0) key_length++; } } -- cgit v1.2.3-70-g09d2