mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 08:58:03 +02:00
trivial: rename nm_utils_ascii_str_to_int64() to _nm_utils_ascii_str_to_int64()
This commit is contained in:
parent
b66deb67fa
commit
093f6d477b
11 changed files with 22 additions and 22 deletions
|
|
@ -1798,7 +1798,7 @@ nm_utils_cmp_connection_by_autoconnect_priority (NMConnection **a, NMConnection
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nm_utils_ascii_str_to_int64:
|
/* _nm_utils_ascii_str_to_int64:
|
||||||
*
|
*
|
||||||
* A wrapper for g_ascii_strtoll, that checks whether the whole string
|
* A wrapper for g_ascii_strtoll, that checks whether the whole string
|
||||||
* can be successfully converted to a number and is within a given
|
* can be successfully converted to a number and is within a given
|
||||||
|
|
@ -1813,7 +1813,7 @@ nm_utils_cmp_connection_by_autoconnect_priority (NMConnection **a, NMConnection
|
||||||
* white space.
|
* white space.
|
||||||
**/
|
**/
|
||||||
gint64
|
gint64
|
||||||
nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback)
|
_nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback)
|
||||||
{
|
{
|
||||||
gint64 v;
|
gint64 v;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ int nm_utils_cmp_connection_by_autoconnect_priority (NMConnection **a, NMConnect
|
||||||
|
|
||||||
void nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base, guint32 level, guint64 domain, const char *name, const char *prefix);
|
void nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base, guint32 level, guint64 domain, const char *name, const char *prefix);
|
||||||
|
|
||||||
gint64 nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback);
|
gint64 _nm_utils_ascii_str_to_int64 (const char *str, guint base, gint64 min, gint64 max, gint64 fallback);
|
||||||
|
|
||||||
#define NM_UTILS_UUID_NS "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905"
|
#define NM_UTILS_UUID_NS "b425e9fb-7598-44b4-9e3b-5a2e3aaa4905"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ handle_event (DBusGProxy *proxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_str = get_option (options, "pid");
|
pid_str = get_option (options, "pid");
|
||||||
pid = nm_utils_ascii_str_to_int64 (pid_str, 10, 0, G_MAXINT32, -1);
|
pid = _nm_utils_ascii_str_to_int64 (pid_str, 10, 0, G_MAXINT32, -1);
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
nm_log_warn (LOGD_DHCP, "DHCP event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
|
nm_log_warn (LOGD_DHCP, "DHCP event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
||||||
|
|
@ -3025,7 +3025,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
|
||||||
val = nm_platform_sysctl_get (path);
|
val = nm_platform_sysctl_get (path);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
if (val) {
|
if (val) {
|
||||||
props->owner = nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1);
|
props->owner = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1);
|
||||||
if (errno)
|
if (errno)
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
g_free (val);
|
g_free (val);
|
||||||
|
|
@ -3036,7 +3036,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
|
||||||
val = nm_platform_sysctl_get (path);
|
val = nm_platform_sysctl_get (path);
|
||||||
g_free (path);
|
g_free (path);
|
||||||
if (val) {
|
if (val) {
|
||||||
props->group = nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1);
|
props->group = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1);
|
||||||
if (errno)
|
if (errno)
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
g_free (val);
|
g_free (val);
|
||||||
|
|
@ -3049,7 +3049,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
|
||||||
if (val) {
|
if (val) {
|
||||||
gint64 flags;
|
gint64 flags;
|
||||||
|
|
||||||
flags = nm_utils_ascii_str_to_int64 (val, 16, 0, G_MAXINT64, 0);
|
flags = _nm_utils_ascii_str_to_int64 (val, 16, 0, G_MAXINT64, 0);
|
||||||
if (!errno) {
|
if (!errno) {
|
||||||
#ifndef IFF_MULTI_QUEUE
|
#ifndef IFF_MULTI_QUEUE
|
||||||
const int IFF_MULTI_QUEUE = 0x0100;
|
const int IFF_MULTI_QUEUE = 0x0100;
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ nm_platform_sysctl_get_int_checked (const char *path, guint base, gint64 min, gi
|
||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = nm_utils_ascii_str_to_int64 (value, base, min, max, fallback);
|
ret = _nm_utils_ascii_str_to_int64 (value, base, min, max, fallback);
|
||||||
g_free (value);
|
g_free (value);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ is_ibft_vlan_device (const GPtrArray *block)
|
||||||
/* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it
|
/* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it
|
||||||
* means "no VLAN".
|
* means "no VLAN".
|
||||||
*/
|
*/
|
||||||
if (nm_utils_ascii_str_to_int64 (s_vlan_id, 10, 1, 4095, -1) != -1)
|
if (_nm_utils_ascii_str_to_int64 (s_vlan_id, 10, 1, 4095, -1) != -1)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
@ -458,7 +458,7 @@ vlan_setting_add_from_block (const GPtrArray *block,
|
||||||
g_assert (vlan_id_str);
|
g_assert (vlan_id_str);
|
||||||
|
|
||||||
/* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it means "no VLAN" */
|
/* VLAN 0 is normally a valid VLAN ID, but in the iBFT case it means "no VLAN" */
|
||||||
vlan_id = nm_utils_ascii_str_to_int64 (vlan_id_str, 10, 1, 4095, -1);
|
vlan_id = _nm_utils_ascii_str_to_int64 (vlan_id_str, 10, 1, 4095, -1);
|
||||||
if (vlan_id == -1) {
|
if (vlan_id == -1) {
|
||||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||||
"Invalid VLAN_ID '%s'", vlan_id_str);
|
"Invalid VLAN_ID '%s'", vlan_id_str);
|
||||||
|
|
|
||||||
|
|
@ -503,7 +503,7 @@ read_one_ip4_route (shvarFile *ifcfg,
|
||||||
/* Metric */
|
/* Metric */
|
||||||
value = svGetValue (ifcfg, metric_tag, FALSE);
|
value = svGetValue (ifcfg, metric_tag, FALSE);
|
||||||
if (value) {
|
if (value) {
|
||||||
metric = nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1);
|
metric = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT32, -1);
|
||||||
if (metric < 0) {
|
if (metric < 0) {
|
||||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||||
"Invalid IP4 route metric '%s'", value);
|
"Invalid IP4 route metric '%s'", value);
|
||||||
|
|
@ -3344,7 +3344,7 @@ make_wireless_setting (shvarFile *ifcfg,
|
||||||
value = svGetValue (ifcfg, "CHANNEL", FALSE);
|
value = svGetValue (ifcfg, "CHANNEL", FALSE);
|
||||||
if (value) {
|
if (value) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
chan = nm_utils_ascii_str_to_int64 (value, 10, 1, 196, 0);
|
chan = _nm_utils_ascii_str_to_int64 (value, 10, 1, 196, 0);
|
||||||
if (errno || (chan == 0)) {
|
if (errno || (chan == 0)) {
|
||||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||||
"Invalid wireless channel '%s'", value);
|
"Invalid wireless channel '%s'", value);
|
||||||
|
|
@ -4889,7 +4889,7 @@ devtimeout_from_file (const char *filename)
|
||||||
|
|
||||||
devtimeout_str = svGetValue (ifcfg, "DEVTIMEOUT", FALSE);
|
devtimeout_str = svGetValue (ifcfg, "DEVTIMEOUT", FALSE);
|
||||||
if (devtimeout_str) {
|
if (devtimeout_str) {
|
||||||
devtimeout = nm_utils_ascii_str_to_int64 (devtimeout_str, 10, 0, G_MAXUINT, 0);
|
devtimeout = _nm_utils_ascii_str_to_int64 (devtimeout_str, 10, 0, G_MAXUINT, 0);
|
||||||
g_free (devtimeout_str);
|
g_free (devtimeout_str);
|
||||||
} else
|
} else
|
||||||
devtimeout = 0;
|
devtimeout = 0;
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ svTrueValue (shvarFile *s, const char *key, gboolean def)
|
||||||
* @max: the maximum for range-check
|
* @max: the maximum for range-check
|
||||||
* @fallback: the fallback value in any error case
|
* @fallback: the fallback value in any error case
|
||||||
*
|
*
|
||||||
* Reads a value @key and converts it to an integer using nm_utils_ascii_str_to_int64().
|
* Reads a value @key and converts it to an integer using _nm_utils_ascii_str_to_int64().
|
||||||
* In case of error, @errno will be set and @fallback returned. */
|
* In case of error, @errno will be set and @fallback returned. */
|
||||||
gint64
|
gint64
|
||||||
svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback)
|
svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 max, gint64 fallback)
|
||||||
|
|
@ -336,7 +336,7 @@ svGetValueInt64 (shvarFile *s, const char *key, guint base, gint64 min, gint64 m
|
||||||
return fallback;
|
return fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = nm_utils_ascii_str_to_int64 (tmp, base, min, max, fallback);
|
result = _nm_utils_ascii_str_to_int64 (tmp, base, min, max, fallback);
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
if (errsv != 0)
|
if (errsv != 0)
|
||||||
PARSE_WARNING ("Error reading '%s' value '%s' as integer (%d)", key, tmp, errsv);
|
PARSE_WARNING ("Error reading '%s' value '%s' as integer (%d)", key, tmp, errsv);
|
||||||
|
|
|
||||||
|
|
@ -706,13 +706,13 @@ make_ip4_setting (NMConnection *connection,
|
||||||
GError *local = NULL;
|
GError *local = NULL;
|
||||||
|
|
||||||
if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL) {
|
if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL) {
|
||||||
metric = nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
|
metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
|
||||||
} else {
|
} else {
|
||||||
metric_str = ifnet_get_global_data ("metric");
|
metric_str = ifnet_get_global_data ("metric");
|
||||||
if (metric_str) {
|
if (metric_str) {
|
||||||
stripped = g_strdup (metric_str);
|
stripped = g_strdup (metric_str);
|
||||||
strip_string (stripped, '"');
|
strip_string (stripped, '"');
|
||||||
metric = nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
|
metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
|
||||||
g_free (stripped);
|
g_free (stripped);
|
||||||
} else
|
} else
|
||||||
metric = -1;
|
metric = -1;
|
||||||
|
|
@ -846,13 +846,13 @@ make_ip6_setting (NMConnection *connection,
|
||||||
/* metric is not per routes configuration right now
|
/* metric is not per routes configuration right now
|
||||||
* global metric is also supported (metric="x") */
|
* global metric is also supported (metric="x") */
|
||||||
if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL)
|
if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL)
|
||||||
metric = nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
|
metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
|
||||||
else {
|
else {
|
||||||
metric_str = ifnet_get_global_data ("metric");
|
metric_str = ifnet_get_global_data ("metric");
|
||||||
if (metric_str) {
|
if (metric_str) {
|
||||||
stripped = g_strdup (metric_str);
|
stripped = g_strdup (metric_str);
|
||||||
strip_string (stripped, '"');
|
strip_string (stripped, '"');
|
||||||
metric = nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
|
metric = _nm_utils_ascii_str_to_int64 (metric_str, 10, 0, G_MAXUINT32, -1);
|
||||||
g_free (stripped);
|
g_free (stripped);
|
||||||
} else
|
} else
|
||||||
metric = 1;
|
metric = 1;
|
||||||
|
|
|
||||||
|
|
@ -1145,7 +1145,7 @@ read_one_setting_value (NMSetting *setting,
|
||||||
gint64 int_val;
|
gint64 int_val;
|
||||||
|
|
||||||
tmp_str = nm_keyfile_plugin_kf_get_value (info->keyfile, setting_name, key, NULL);
|
tmp_str = nm_keyfile_plugin_kf_get_value (info->keyfile, setting_name, key, NULL);
|
||||||
int_val = nm_utils_ascii_str_to_int64 (tmp_str, 10, G_MININT64, G_MAXINT64, 0);
|
int_val = _nm_utils_ascii_str_to_int64 (tmp_str, 10, G_MININT64, G_MAXINT64, 0);
|
||||||
errsv = errno;
|
errsv = errno;
|
||||||
if (errsv)
|
if (errsv)
|
||||||
nm_log_warn (LOGD_SETTINGS, "Invalid int64 value (%s)", tmp_str);
|
nm_log_warn (LOGD_SETTINGS, "Invalid int64 value (%s)", tmp_str);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ test_nm_utils_ascii_str_to_int64_check (const char *str, guint base, gint64 min,
|
||||||
gint64 v;
|
gint64 v;
|
||||||
|
|
||||||
errno = 1;
|
errno = 1;
|
||||||
v = nm_utils_ascii_str_to_int64 (str, base, min, max, fallback);
|
v = _nm_utils_ascii_str_to_int64 (str, base, min, max, fallback);
|
||||||
g_assert_cmpint (errno, ==, exp_errno);
|
g_assert_cmpint (errno, ==, exp_errno);
|
||||||
g_assert_cmpint (v, ==, exp_val);
|
g_assert_cmpint (v, ==, exp_val);
|
||||||
}
|
}
|
||||||
|
|
@ -893,7 +893,7 @@ main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
nmtst_init_with_logging (&argc, &argv, NULL, "ALL");
|
nmtst_init_with_logging (&argc, &argv, NULL, "ALL");
|
||||||
|
|
||||||
g_test_add_func ("/general/nm_utils_ascii_str_to_int64", test_nm_utils_ascii_str_to_int64);
|
g_test_add_func ("/general/_nm_utils_ascii_str_to_int64", test_nm_utils_ascii_str_to_int64);
|
||||||
g_test_add_func ("/general/nm_utils_ip6_address_clear_host_address", test_nm_utils_ip6_address_clear_host_address);
|
g_test_add_func ("/general/nm_utils_ip6_address_clear_host_address", test_nm_utils_ip6_address_clear_host_address);
|
||||||
g_test_add_func ("/general/nm_utils_log_connection_diff", test_nm_utils_log_connection_diff);
|
g_test_add_func ("/general/nm_utils_log_connection_diff", test_nm_utils_log_connection_diff);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue