mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 19:18:00 +02:00
initrd: cmdline-reader: fix setting uint properties
Previously a uint property was assigned with a guint64 value, which has a different size. Fix this and add a warning when the read value can't be converted. Fixes:ecc074b2f8https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/66 (cherry picked from commitd0a99176a7)
This commit is contained in:
parent
147081bd72
commit
2e5d0f3046
1 changed files with 11 additions and 3 deletions
|
|
@ -138,9 +138,17 @@ _base_setting_set (NMConnection *connection, const char *property, const char *v
|
|||
|
||||
setting = nm_connection_get_setting_by_name (connection, type_name);
|
||||
|
||||
if (G_IS_PARAM_SPEC_UINT (spec))
|
||||
g_object_set (setting, property, g_ascii_strtoull (value, NULL, 10), NULL);
|
||||
else if (G_IS_PARAM_SPEC_STRING (spec))
|
||||
if (G_IS_PARAM_SPEC_UINT (spec)) {
|
||||
guint v;
|
||||
|
||||
v = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXUINT, 0);
|
||||
if ( errno
|
||||
|| !nm_g_object_set_property_uint (G_OBJECT (setting), property, v, NULL)) {
|
||||
_LOGW (LOGD_CORE,
|
||||
"Could not set property '%s.%s' to '%s'",
|
||||
type_name, property, value);
|
||||
}
|
||||
} else if (G_IS_PARAM_SPEC_STRING (spec))
|
||||
g_object_set (setting, property, value, NULL);
|
||||
else
|
||||
_LOGW (LOGD_CORE, "Don't know how to set '%s' of %s\n", property, type_name);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue