From 1168489cd405249cb46907081a94548f401ea3f0 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 21 Nov 2024 01:21:28 +0900 Subject: [PATCH] network/ndisc: constify several arguments and add several assertions Follow-up for 0f8afaf94dd29126981219b3ea2b3bc315cc2dd0. No functional change, just for safety. --- src/network/networkd-ndisc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 33e86fb04e4..e778300c70c 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -215,7 +215,7 @@ static int ndisc_remove_unused_nexthops(Link *link) { #define NDISC_NEXTHOP_APP_ID SD_ID128_MAKE(76,d2,0f,1f,76,1e,44,d1,97,3a,52,5c,05,68,b5,0d) -static uint32_t ndisc_generate_nexthop_id(NextHop *nexthop, Link *link, sd_id128_t app_id, uint64_t trial) { +static uint32_t ndisc_generate_nexthop_id(const NextHop *nexthop, Link *link, sd_id128_t app_id, uint64_t trial) { assert(nexthop); assert(link); @@ -232,7 +232,7 @@ static uint32_t ndisc_generate_nexthop_id(NextHop *nexthop, Link *link, sd_id128 return (uint32_t) ((result & 0xffffffff) ^ (result >> 32)); } -static bool ndisc_nexthop_equal(NextHop *a, NextHop *b) { +static bool ndisc_nexthop_equal(const NextHop *a, const NextHop *b) { assert(a); assert(b); @@ -250,9 +250,11 @@ static bool ndisc_nexthop_equal(NextHop *a, NextHop *b) { return true; } -static bool ndisc_take_nexthop_id(NextHop *nexthop, NextHop *existing, Manager *manager) { +static bool ndisc_take_nexthop_id(NextHop *nexthop, const NextHop *existing, Manager *manager) { assert(nexthop); + assert(nexthop->id == 0); assert(existing); + assert(existing->id > 0); assert(manager); if (!ndisc_nexthop_equal(nexthop, existing)) @@ -300,7 +302,7 @@ static int ndisc_nexthop_find_id(NextHop *nexthop, Link *link) { return false; } -static int ndisc_nexthop_new(Route *route, Link *link, NextHop **ret) { +static int ndisc_nexthop_new(const Route *route, Link *link, NextHop **ret) { _cleanup_(nexthop_unrefp) NextHop *nexthop = NULL; int r;