all: use c_list_is_empty_or_single() where appropriate

This commit is contained in:
Thomas Haller 2023-03-07 10:55:12 +01:00
parent 4733cf7460
commit 5558498721
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
3 changed files with 5 additions and 4 deletions

View file

@ -695,7 +695,7 @@ nm_netns_ip_route_ecmp_commit(NMNetns *self,
/* This route is onlink. We don't need to configure an onlink route
* to the gateway, and the route is immediately ready for configuration. */
track_obj->is_ready = TRUE;
} else if (c_list_length_is(&track_ecmpid->ecmpid_lst_head, 1)) {
} else if (c_list_is_empty_or_single(&track_ecmpid->ecmpid_lst_head)) {
/* This route has no merge partner and ends up being a
* single hop route. It will be returned and configured by
* the calling "l3cfg".

View file

@ -97,7 +97,7 @@ _entry_lookup_head(const NMDedupMultiIndex *self,
if (c_list_is_empty(&idx_type->lst_idx_head))
head_entry = NULL;
else {
nm_assert(c_list_length(&idx_type->lst_idx_head) == 1);
nm_assert(c_list_length_is(&idx_type->lst_idx_head, 1));
head_entry = c_list_entry(idx_type->lst_idx_head.next, NMDedupMultiHeadEntry, lst_idx);
}
nm_assert(head_entry == g_hash_table_lookup(self->idx_entries, &stack_entry));

View file

@ -540,12 +540,13 @@ _track_data_untrack(NMPGlobalTracker *self,
* sync. */
obj_data->config_state = CONFIG_STATE_OWNED_BY_US;
}
} else if (remove_user_tag_data && c_list_length_is(&track_data->user_tag_lst, 1))
} else if (remove_user_tag_data && c_list_is_empty_or_single(&track_data->user_tag_lst))
g_hash_table_remove(self->by_user_tag, &track_data->user_tag);
/* if obj_data is marked to be "added_by_us" or "removed_by_us", we need to keep this entry
* around for the next sync -- so that we can undo what we did earlier. */
if (obj_data->config_state == CONFIG_STATE_NONE && c_list_length_is(&track_data->obj_lst, 1))
if (obj_data->config_state == CONFIG_STATE_NONE
&& c_list_is_empty_or_single(&track_data->obj_lst))
g_hash_table_remove(self->by_obj, &track_data->obj);
g_hash_table_remove(self->by_data, track_data);