mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-07 05:10:36 +01:00
cli: avoid duplicate delimiters when printing objlist property
Usually, obj_to_str_fcn() should not fail and always add something.
If not, remove the delimiter again.
(cherry picked from commit 720bc30bd9)
This commit is contained in:
parent
3383bb4feb
commit
53ab539dd1
1 changed files with 8 additions and 4 deletions
|
|
@ -3053,9 +3053,7 @@ _get_fcn_objlist (ARGS_GET_FCN)
|
|||
num = property_info->property_typ_data->subtype.objlist.get_num_fcn (setting);
|
||||
|
||||
for (idx = 0; idx < num; idx++) {
|
||||
#if NM_MORE_ASSERTS
|
||||
gsize start_offset;
|
||||
#endif
|
||||
|
||||
if (!str)
|
||||
str = g_string_new (NULL);
|
||||
|
|
@ -3067,15 +3065,21 @@ _get_fcn_objlist (ARGS_GET_FCN)
|
|||
g_string_append (str, ", ");
|
||||
}
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
start_offset = str->len;
|
||||
#endif
|
||||
|
||||
property_info->property_typ_data->subtype.objlist.obj_to_str_fcn (get_type,
|
||||
setting,
|
||||
idx,
|
||||
str);
|
||||
|
||||
if (start_offset == str->len) {
|
||||
/* nothing was appended. Remove the delimiter again. */
|
||||
nm_assert_not_reached ();
|
||||
if (str->len > 0)
|
||||
g_string_truncate (str, str->len - 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
nm_assert (start_offset < str->len);
|
||||
if ( property_info->property_typ_data->subtype.objlist.strsplit_with_escape
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue