if (r < 0)
return r;
- *ret = link;
- link = NULL;
+ *ret = TAKE_PTR(link);
return 0;
}
if (r < 0)
return log_link_error_errno(link, r, "Failed to add route: %m");
- if (lifetime != USEC_INFINITY) {
+ if (lifetime != USEC_INFINITY && !kernel_route_expiration_supported()) {
r = sd_event_add_time(link->manager->event, &expire, clock_boottime_or_monotonic(), lifetime,
0, route_expire_handler, route);
if (r < 0)
route->lifetime = lifetime;
sd_event_source_unref(route->expire);
- route->expire = expire;
- expire = NULL;
+ route->expire = TAKE_PTR(expire);
}
}