mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 20:45:32 +00:00
shared: add c-list macros to iterate backwards
This commit is contained in:
parent
5b7ce438d9
commit
dfd2fcde0f
|
@ -66,9 +66,12 @@ SpacesInContainerLiterals: false
|
||||||
SpacesInParentheses: false
|
SpacesInParentheses: false
|
||||||
|
|
||||||
ForEachMacros: ['c_list_for_each',
|
ForEachMacros: ['c_list_for_each',
|
||||||
|
'c_list_for_each_prev',
|
||||||
|
'c_list_for_each_prev_safe',
|
||||||
'c_list_for_each_continue',
|
'c_list_for_each_continue',
|
||||||
'c_list_for_each_entry',
|
'c_list_for_each_entry',
|
||||||
'c_list_for_each_entry_continue',
|
'c_list_for_each_entry_continue',
|
||||||
|
'c_list_for_each_entry_prev',
|
||||||
'c_list_for_each_entry_safe',
|
'c_list_for_each_entry_safe',
|
||||||
'c_list_for_each_entry_safe_continue',
|
'c_list_for_each_entry_safe_continue',
|
||||||
'c_list_for_each_entry_safe_unlink',
|
'c_list_for_each_entry_safe_unlink',
|
||||||
|
@ -93,7 +96,6 @@ ForEachMacros: ['c_list_for_each',
|
||||||
'ndp_msg_opt_rdnss_for_each_addr',
|
'ndp_msg_opt_rdnss_for_each_addr',
|
||||||
'nla_for_each_attr',
|
'nla_for_each_attr',
|
||||||
'nla_for_each_nested',
|
'nla_for_each_nested',
|
||||||
'nm_c_list_for_each_entry_prev',
|
|
||||||
'nm_dedup_multi_iter_for_each',
|
'nm_dedup_multi_iter_for_each',
|
||||||
'nm_ip_config_iter_ip4_address_for_each',
|
'nm_ip_config_iter_ip4_address_for_each',
|
||||||
'nm_ip_config_iter_ip4_route_for_each',
|
'nm_ip_config_iter_ip4_route_for_each',
|
||||||
|
|
|
@ -1166,7 +1166,7 @@ nml_dbus_object_iface_data_get(NMLDBusObject *dbobj,
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nm_c_list_for_each_entry_prev (db_iface_data, &dbobj->iface_lst_head, iface_lst) {
|
c_list_for_each_entry_prev (db_iface_data, &dbobj->iface_lst_head, iface_lst) {
|
||||||
if (db_iface_data->dbus_iface_is_wellknown)
|
if (db_iface_data->dbus_iface_is_wellknown)
|
||||||
break;
|
break;
|
||||||
if (db_iface_data->iface_removed)
|
if (db_iface_data->iface_removed)
|
||||||
|
|
|
@ -17,11 +17,6 @@
|
||||||
_what &&c_list_contains(list, &_what->member); \
|
_what &&c_list_contains(list, &_what->member); \
|
||||||
})
|
})
|
||||||
|
|
||||||
/* iterate over the list backwards. */
|
|
||||||
#define nm_c_list_for_each_entry_prev(_iter, _list, _m) \
|
|
||||||
for (_iter = c_list_entry((_list)->prev, __typeof__(*_iter), _m); &(_iter)->_m != (_list); \
|
|
||||||
_iter = c_list_entry((_iter)->_m.prev, __typeof__(*_iter), _m))
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -42,4 +42,15 @@ c_list_length_is(const CList *list, unsigned long check_len)
|
||||||
return n == check_len;
|
return n == check_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define c_list_for_each_prev(_iter, _list) \
|
||||||
|
for (_iter = (_list)->prev; (_iter) != (_list); _iter = (_iter)->prev)
|
||||||
|
|
||||||
|
#define c_list_for_each_prev_safe(_iter, _safe, _list) \
|
||||||
|
for (_iter = (_list)->prev, _safe = (_iter)->prev; (_iter) != (_list); \
|
||||||
|
_iter = (_safe), _safe = (_safe)->prev)
|
||||||
|
|
||||||
|
#define c_list_for_each_entry_prev(_iter, _list, _m) \
|
||||||
|
for (_iter = c_list_entry((_list)->prev, __typeof__(*_iter), _m); &(_iter)->_m != (_list); \
|
||||||
|
_iter = c_list_entry((_iter)->_m.prev, __typeof__(*_iter), _m))
|
||||||
|
|
||||||
#endif /* __C_LIST_UTIL_H__ */
|
#endif /* __C_LIST_UTIL_H__ */
|
||||||
|
|
Loading…
Reference in a new issue