summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-02-21 09:47:23 +0100
committerThomas Haller <thaller@redhat.com>2019-02-22 14:04:13 +0100
commit3059a30da9707055ca14d24f50469f7427901caf (patch)
tree57b191dcf4c39c5006a361d81c47a0be418394b8
parent9d0da3e60bbb9e5fb209eeec572adfa29b2cbce2 (diff)
downloadNetworkManager-3059a30da9707055ca14d24f50469f7427901caf.tar.gz
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.
-rw-r--r--clients/common/nm-meta-setting-desc.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index 05a8689b91..c112343aeb 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -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);
+ data = g_bytes_get_data (bytes, &len);
+ return nm_utils_bin2hexstr_full (data,
+ len,
+ '\0',
+ TRUE,
+ NULL);
}
static char *