diff options
author | Thomas Haller <thaller@redhat.com> | 2019-02-21 09:47:23 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-02-22 14:04:13 +0100 |
commit | 3059a30da9707055ca14d24f50469f7427901caf (patch) | |
tree | 57b191dcf4c39c5006a361d81c47a0be418394b8 | |
parent | 9d0da3e60bbb9e5fb209eeec572adfa29b2cbce2 (diff) | |
download | NetworkManager-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.c | 14 |
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 * |