int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
_cleanup_free_ char *addr_p = NULL;
- sd_radv_prefix *cur;
- bool update = false;
+ sd_radv_prefix *cur, *found = NULL;
int r;
assert_return(ra, -EINVAL);
continue;
if (cur->opt.prefixlen == p->opt.prefixlen) {
- update = true;
+ found = cur;
break;
}
strna(addr_p), strna(addr_cur));
}
- if (update) {
- assert(cur);
-
+ if (found) {
/* p and cur may be equivalent. First increment the reference counter. */
sd_radv_prefix_ref(p);
/* Then, remove the old entry. */
- LIST_REMOVE(prefix, ra->prefixes, cur);
- sd_radv_prefix_unref(cur);
+ LIST_REMOVE(prefix, ra->prefixes, found);
+ sd_radv_prefix_unref(found);
/* Finally, add the new entry. */
LIST_APPEND(prefix, ra->prefixes, p);
int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) {
_cleanup_free_ char *addr_p = NULL;
- sd_radv_route_prefix *cur;
- bool update = false;
+ sd_radv_route_prefix *cur, *found = NULL;
int r;
assert_return(ra, -EINVAL);
continue;
if (cur->opt.prefixlen == p->opt.prefixlen) {
- update = true;
+ found = cur;
break;
}
strna(addr_p), strna(addr_cur));
}
- if (update) {
- assert(cur);
-
+ if (found) {
/* p and cur may be equivalent. First increment the reference counter. */
sd_radv_route_prefix_ref(p);
/* Then, remove the old entry. */
- LIST_REMOVE(prefix, ra->route_prefixes, cur);
- sd_radv_route_prefix_unref(cur);
+ LIST_REMOVE(prefix, ra->route_prefixes, found);
+ sd_radv_route_prefix_unref(found);
/* Finally, add the new entry. */
LIST_APPEND(prefix, ra->route_prefixes, p);