From 41ef7327e3ebf9f0293c6046190aceb9d44f8414 Mon Sep 17 00:00:00 2001 From: Christian Hopps Date: Thu, 23 Feb 2023 20:23:51 -0500 Subject: lib: fix init. use of nb_context to be by value not by reference Pass context argument by value on initialization to be clear that the value is used/saved but not a pointer to the value. Previously the northbound code was incorrectly holding a pointer to stack allocated context structs. However, the structure definition also had some musings (ifdef'd out code) and a comment that might be taken to imply that user data could follow the structure and thus be maintained by the code; it won't; so it can't; so get rid of the disabled misleading code/text from the structure definition. The common use case worked b/c the transaction which cached the pointer was created and freed inside a single function call (`nb_condidate_commit`) that executed below the stack allocation. All other use cases (grpc, confd, sysrepo, and -- coming soon -- mgmtd) were bugs. Signed-off-by: Christian Hopps --- lib/libfrr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libfrr.c') diff --git a/lib/libfrr.c b/lib/libfrr.c index 0467dc1d7e..d1b7dd133e 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -992,7 +992,7 @@ static void frr_config_read_in(struct thread *t) int ret; context.client = NB_CLIENT_CLI; - ret = nb_candidate_commit(&context, vty_shared_candidate_config, + ret = nb_candidate_commit(context, vty_shared_candidate_config, true, "Read configuration file", NULL, errmsg, sizeof(errmsg)); if (ret != NB_OK && ret != NB_ERR_NO_CHANGES) -- cgit v1.2.3