mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-18 23:50:36 +01:00
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:
parent
9d0da3e60b
commit
3059a30da9
1 changed files with 6 additions and 8 deletions
|
|
@ -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 *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue