summaryrefslogtreecommitdiff
path: root/lib/northbound.h
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2023-02-23 20:23:51 -0500
committerChristian Hopps <chopps@labn.net>2023-02-23 20:59:17 -0500
commit41ef7327e3ebf9f0293c6046190aceb9d44f8414 (patch)
tree76bac8831c49014cdb6edf1698a4b6851623c490 /lib/northbound.h
parentce8194bcd09bebfd2641ffeeb48ad3e8b527182b (diff)
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 <chopps@labn.net>
Diffstat (limited to 'lib/northbound.h')
-rw-r--r--lib/northbound.h22
1 files changed, 3 insertions, 19 deletions
diff --git a/lib/northbound.h b/lib/northbound.h
index c132daebdb..152810b3a9 100644
--- a/lib/northbound.h
+++ b/lib/northbound.h
@@ -622,22 +622,6 @@ struct nb_context {
/* Northbound user (can be NULL). */
const void *user;
-
- /* Client-specific data. */
-#if 0
- union {
- struct {
- } cli;
- struct {
- } confd;
- struct {
- } sysrepo;
- struct {
- } grpc;
- struct {
- } pcep;
- } client_data;
-#endif
};
/* Northbound configuration. */
@@ -666,7 +650,7 @@ struct nb_config_change {
/* Northbound configuration transaction. */
struct nb_transaction {
- struct nb_context *context;
+ struct nb_context context;
char comment[80];
struct nb_config *config;
struct nb_config_cbs changes;
@@ -927,7 +911,7 @@ extern int nb_candidate_validate(struct nb_context *context,
* the candidate configuration.
* - NB_ERR for other errors.
*/
-extern int nb_candidate_commit_prepare(struct nb_context *context,
+extern int nb_candidate_commit_prepare(struct nb_context context,
struct nb_config *candidate,
const char *comment,
struct nb_transaction **transaction,
@@ -1014,7 +998,7 @@ extern void nb_candidate_commit_apply(struct nb_transaction *transaction,
* the candidate configuration.
* - NB_ERR for other errors.
*/
-extern int nb_candidate_commit(struct nb_context *context,
+extern int nb_candidate_commit(struct nb_context context,
struct nb_config *candidate,
bool save_transaction, const char *comment,
uint32_t *transaction_id, char *errmsg,