summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/sd-radv.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-16 13:12:37 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-03-17 06:34:58 +0100
commit95931532aa0f9f951454a45e078a49dca4341dfc (patch)
treec02faf8f5f899e7a5f8937303e6c79a60f322b3f /src/libsystemd-network/sd-radv.c
parenttpm2: enable parameter encryption (diff)
downloadsystemd-95931532aa0f9f951454a45e078a49dca4341dfc.tar.xz
systemd-95931532aa0f9f951454a45e078a49dca4341dfc.zip
sd-radv: voidify sd_radv_remove_prefix()
If the prefix is only referenced by sd_radv, then the returned pointer is already freed. networkd does not uses the returned value. Let's voidify the function.
Diffstat (limited to 'src/libsystemd-network/sd-radv.c')
-rw-r--r--src/libsystemd-network/sd-radv.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c
index e332f6a2ab..752c09d890 100644
--- a/src/libsystemd-network/sd-radv.c
+++ b/src/libsystemd-network/sd-radv.c
@@ -659,15 +659,20 @@ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p) {
return 0;
}
-sd_radv_prefix *sd_radv_remove_prefix(sd_radv *ra,
- const struct in6_addr *prefix,
- unsigned char prefixlen) {
- sd_radv_prefix *cur, *next;
+void sd_radv_remove_prefix(
+ sd_radv *ra,
+ const struct in6_addr *prefix,
+ unsigned char prefixlen) {
- assert_return(ra, NULL);
- assert_return(prefix, NULL);
+ sd_radv_prefix *cur;
+
+ if (!ra)
+ return;
- LIST_FOREACH_SAFE(prefix, cur, next, ra->prefixes) {
+ if (!prefix)
+ return;
+
+ LIST_FOREACH(prefix, cur, ra->prefixes) {
if (prefixlen != cur->opt.prefixlen)
continue;
@@ -677,11 +682,8 @@ sd_radv_prefix *sd_radv_remove_prefix(sd_radv *ra,
LIST_REMOVE(prefix, ra->prefixes, cur);
ra->n_prefixes--;
sd_radv_prefix_unref(cur);
-
- break;
+ return;
}
-
- return cur;
}
int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p) {