diff options
author | Thomas Haller <thaller@redhat.com> | 2018-09-27 16:05:29 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-09-30 13:36:57 +0200 |
commit | b537c0388a0ca7320d01c9ba2c6b5b4fe45f267f (patch) | |
tree | e94e83488744e5eb8e4d75ba21d112b98a59e47a | |
parent | 21df8d38effc8d9a36d7f2ac5fb674ddbf848a25 (diff) | |
download | NetworkManager-b537c0388a0ca7320d01c9ba2c6b5b4fe45f267f.tar.gz |
all: drop _nm_utils_bin2hexstr()
We already have nm_utils_bin2hexstr() and _nm_utils_bin2hexstr_full().
This is confusing.
- nm_utils_bin2hexstr() is public API of libnm. Also, it has
a last argument @final_len to truncate the string at that
length.
It uses no delimiter and lower-case characters.
- _nm_utils_bin2hexstr_full() does not do any truncation, but
it has options to specify a delimiter, the character case,
and to update a given buffer in-place. Also, like
nm_utils_bin2hexstr() and _nm_utils_bin2hexstr() it can
allocate a new buffer on demand.
- _nm_utils_bin2hexstr() would use ':' as delimiter and make
the case configurable. Also, it would always allocate the returned
buffer.
It's too much and confusing. Drop _nm_utils_bin2hexstr() which is internal
API and just a wrapper around _nm_utils_bin2hexstr_full().
-rw-r--r-- | libnm-core/nm-core-internal.h | 1 | ||||
-rw-r--r-- | libnm-core/nm-utils.c | 19 | ||||
-rw-r--r-- | src/devices/nm-device.c | 16 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-utils.c | 4 |
4 files changed, 12 insertions, 28 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index 64dca77720..6f4da1adc5 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -212,7 +212,6 @@ guint nm_setting_ethtool_init_features (NMSettingEthtool *setting, guint8 *_nm_utils_hwaddr_aton (const char *asc, gpointer buffer, gsize buffer_length, gsize *out_length); const char *nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_case, char *buf, gsize buf_len); -char *_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case); char *_nm_utils_bin2hexstr_full (gconstpointer addr, gsize length, const char delimiter, gboolean upper_case, char *out); guint8 *_nm_utils_hexstr2bin_full (const char *asc, diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index f63b8ef8dc..8b22dffdb2 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -3851,25 +3851,6 @@ nm_utils_hwaddr_ntoa_buf (gconstpointer addr, gsize addr_len, gboolean upper_cas } /** - * _nm_utils_bin2hexstr: - * @addr: (type guint8) (array length=length): a binary hardware address - * @length: the length of @addr - * @upper_case: the case for the hexadecimal digits. - * - * Converts @addr to textual form. - * - * Return value: (transfer full): the textual form of @addr - */ -char * -_nm_utils_bin2hexstr (gconstpointer addr, gsize length, gboolean upper_case) -{ - g_return_val_if_fail (addr, g_strdup ("")); - g_return_val_if_fail (length > 0, g_strdup ("")); - - return _nm_utils_bin2hexstr_full (addr, length, ':', upper_case, NULL); -} - -/** * nm_utils_hwaddr_valid: * @asc: the ASCII representation of a hardware address * @length: the length of address that @asc is expected to convert to diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index ae88b567e8..a232f5ccf6 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -14417,9 +14417,11 @@ nm_device_spawn_iface_helper (NMDevice *self) if (client_id) { g_ptr_array_add (argv, g_strdup ("--dhcp4-clientid")); g_ptr_array_add (argv, - _nm_utils_bin2hexstr (g_bytes_get_data (client_id, NULL), - g_bytes_get_size (client_id), - FALSE)); + _nm_utils_bin2hexstr_full (g_bytes_get_data (client_id, NULL), + g_bytes_get_size (client_id), + ':', + FALSE, + NULL)); } hostname = nm_dhcp_client_get_hostname (priv->dhcp4.client); @@ -14457,9 +14459,11 @@ nm_device_spawn_iface_helper (NMDevice *self) if (nm_device_get_ip_iface_identifier (self, &iid, FALSE)) { g_ptr_array_add (argv, g_strdup ("--iid")); g_ptr_array_add (argv, - _nm_utils_bin2hexstr (iid.id_u8, - sizeof (NMUtilsIPv6IfaceId), - FALSE)); + _nm_utils_bin2hexstr_full (iid.id_u8, + sizeof (NMUtilsIPv6IfaceId), + ':', + FALSE, + NULL)); } g_ptr_array_add (argv, g_strdup ("--addr-gen-mode")); diff --git a/src/dhcp/nm-dhcp-utils.c b/src/dhcp/nm-dhcp-utils.c index f6d97b5ffc..9b1653b8f9 100644 --- a/src/dhcp/nm-dhcp-utils.c +++ b/src/dhcp/nm-dhcp-utils.c @@ -726,10 +726,10 @@ nm_dhcp_utils_duid_to_string (GBytes *duid) gconstpointer data; gsize len; - g_return_val_if_fail (duid != NULL, NULL); + g_return_val_if_fail (duid, NULL); data = g_bytes_get_data (duid, &len); - return _nm_utils_bin2hexstr (data, len, FALSE); + return _nm_utils_bin2hexstr_full (data, len, ':', FALSE, NULL); } /** |