cli: use nm_utils_bin2hexstr_full() in nmcli to convert bytes to string

- it's less lines of code (for the caller).

 - it's a function that can be easier unit-tested on its own.
   Possibly there are already other unit-tests that cover it.

 - it's more efficient than the GString based implementation.

 - it reuses our one and only bin-to-hexstr implementation.
This commit is contained in:
Thomas Haller 2019-02-21 09:47:23 +01:00
parent 9d0da3e60b
commit 3059a30da9

View file

@ -1513,18 +1513,16 @@ bytes_to_string (GBytes *bytes)
{
const guint8 *data;
gsize len;
GString *cert = NULL;
int i;
if (!bytes)
return NULL;
data = g_bytes_get_data (bytes, &len);
cert = g_string_new (NULL);
for (i = 0; i < len; i++)
g_string_append_printf (cert, "%02X", data[i]);
return g_string_free (cert, FALSE);
return nm_utils_bin2hexstr_full (data,
len,
'\0',
TRUE,
NULL);
}
static char *