mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 21:40:08 +01:00
libnm: avoid g_warning() in nm_vpn_service_plugin_read_vpn_details()
g_warning() and printing to stdout/stderr are not suitable actions for a library. If there is something important, find a way to report the condition to the caller. If it's not important, stay quiet.
This commit is contained in:
parent
f0dc95e517
commit
ddf1942bfb
2 changed files with 5 additions and 12 deletions
|
|
@ -807,29 +807,23 @@ nm_vpn_service_plugin_read_vpn_details(int fd, GHashTable **out_data, GHashTable
|
|||
/* finish marker */
|
||||
break;
|
||||
} else if (NM_STR_HAS_PREFIX(line->str, DATA_KEY_TAG)) {
|
||||
if (nm_clear_g_string(&key))
|
||||
g_warning("a value expected");
|
||||
nm_clear_g_string(&key);
|
||||
key = g_string_new(line->str + strlen(DATA_KEY_TAG));
|
||||
str = key;
|
||||
hash = data;
|
||||
} else if (NM_STR_HAS_PREFIX(line->str, DATA_VAL_TAG)) {
|
||||
if (val || !key || hash != data) {
|
||||
g_warning("%s not preceded by %s", DATA_VAL_TAG, DATA_KEY_TAG);
|
||||
if (val || !key || hash != data)
|
||||
break;
|
||||
}
|
||||
val = g_string_new(line->str + strlen(DATA_VAL_TAG));
|
||||
str = val;
|
||||
} else if (NM_STR_HAS_PREFIX(line->str, SECRET_KEY_TAG)) {
|
||||
if (nm_clear_g_string(&key))
|
||||
g_warning("a value expected");
|
||||
nm_clear_g_string(&key);
|
||||
key = g_string_new(line->str + strlen(SECRET_KEY_TAG));
|
||||
str = key;
|
||||
hash = secrets;
|
||||
} else if (NM_STR_HAS_PREFIX(line->str, SECRET_VAL_TAG)) {
|
||||
if (val || !key || hash != secrets) {
|
||||
g_warning("%s not preceded by %s", SECRET_VAL_TAG, SECRET_KEY_TAG);
|
||||
if (val || !key || hash != secrets)
|
||||
break;
|
||||
}
|
||||
val = g_string_new(line->str + strlen(SECRET_VAL_TAG));
|
||||
str = val;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2462,8 +2462,7 @@ test_nm_vpn_service_plugin_read_vpn_details(void)
|
|||
"DONE\n"
|
||||
"",
|
||||
READ_VPN_DETAIL_DATA({"some-key", "string\ncontinued after a line break"}, ),
|
||||
READ_VPN_DETAIL_DATA({"key names\ncan have\ncontinuations too", "value"}, ),
|
||||
NMTST_EXPECT_LIBNM_WARNING("DATA_VAL= not preceded by DATA_KEY="));
|
||||
READ_VPN_DETAIL_DATA({"key names\ncan have\ncontinuations too", "value"}, ), );
|
||||
|
||||
_do_read_vpn_details(
|
||||
""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue