summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-03-09 16:58:20 +0100
committerThomas Haller <thaller@redhat.com>2020-03-16 13:40:51 +0100
commit652de3b8d21af459819812fc9c80330191a191b5 (patch)
tree59dcfab1a18c4d57e7085dc9db2e31f9023d455a
parentb7e171c1f7e4067000b7e4d050471847de964ea7 (diff)
downloadNetworkManager-652de3b8d21af459819812fc9c80330191a191b5.tar.gz
cli: use nm_utils_bin2hexstr_full() in ssid_to_hex()
We already have an implementation for converting a binary array to hex. And, it doesn't require a GString for constructing the output that has an known length.
-rw-r--r--clients/cli/utils.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/clients/cli/utils.c b/clients/cli/utils.c
index 2e3a38f735..64a7cde07e 100644
--- a/clients/cli/utils.c
+++ b/clients/cli/utils.c
@@ -321,19 +321,14 @@ nmc_parse_args (nmc_arg_t *arg_arr, gboolean last, int *argc, char ***argv, GErr
char *
ssid_to_hex (const char *str, gsize len)
{
- GString *printable;
- char *printable_str;
- int i;
-
- if (str == NULL || len == 0)
+ if (len == 0)
return NULL;
- printable = g_string_new (NULL);
- for (i = 0; i < len; i++) {
- g_string_append_printf (printable, "%02X", (unsigned char) str[i]);
- }
- printable_str = g_string_free (printable, FALSE);
- return printable_str;
+ return nm_utils_bin2hexstr_full (str,
+ len,
+ '\0',
+ TRUE,
+ NULL);
}
/*