Replace strdup_or_null() by strdup_to()

I didn't know that this helper existed… It is very similar to strdup_to_full(),
but all callers can actually be replaced by strdup_to(), which has more fitting
semantics.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2024-03-20 15:18:21 +01:00
parent f174b294f6
commit 6a705f1234
7 changed files with 17 additions and 43 deletions
+2 -2
View File
@@ -613,12 +613,12 @@ int address_dup(const Address *src, Address **ret) {
dest->nft_set_context.n_sets = 0;
if (src->family == AF_INET) {
r = strdup_or_null(src->label, &dest->label);
r = strdup_to(&dest->label, src->label);
if (r < 0)
return r;
}
r = strdup_or_null(src->netlabel, &dest->netlabel);
r = strdup_to(&dest->netlabel, src->netlabel);
if (r < 0)
return r;
+1 -1
View File
@@ -39,7 +39,7 @@ int route_metric_copy(const RouteMetric *src, RouteMetric *dest) {
} else
dest->metrics_set = NULL;
return strdup_or_null(src->tcp_congestion_control_algo, &dest->tcp_congestion_control_algo);
return strdup_to(&dest->tcp_congestion_control_algo, src->tcp_congestion_control_algo);
}
void route_metric_hash_func(const RouteMetric *metric, struct siphash *state) {
+1 -1
View File
@@ -218,7 +218,7 @@ static int route_nexthop_copy(const RouteNextHop *src, RouteNextHop *dest) {
/* unset pointer copied in the above. */
dest->ifname = NULL;
return strdup_or_null(src->ifindex > 0 ? NULL : src->ifname, &dest->ifname);
return strdup_to(&dest->ifname, src->ifindex > 0 ? NULL : src->ifname);
}
static int route_nexthop_dup(const RouteNextHop *src, RouteNextHop **ret) {