neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/32562 )
Change subject: vty: fix vty->index for implicit go_parent_node ...................................................................... vty: fix vty->index for implicit go_parent_node After this patch, most vty_go_parent() functions are really obsolete, as originally intended: A vty_go_parent() is only needed if the program requires an action to run on VTY node exit. vty_transcript_test.vty shows the fixed behavior. For details, see preceding patch "vty: show bug in implicit go_parent_node" I2472daed7436a1947655b06d34eb217e595bc7f3 Change-Id: Id408c678d18ba19b1c1394c3fb657536153d2094 --- M include/osmocom/vty/vty.h M src/vty/command.c M tests/vty/vty_transcript_test.vty 3 files changed, 27 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/62/32562/1 diff --git a/include/osmocom/vty/vty.h b/include/osmocom/vty/vty.h index ed9f439..155501e 100644 --- a/include/osmocom/vty/vty.h +++ b/include/osmocom/vty/vty.h @@ -61,6 +61,7 @@ /*! private data, specified by creator */ void *priv; + void *index; /*! Node status of this vty */ int node; diff --git a/src/vty/command.c b/src/vty/command.c index 1e76474..a60b544 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -2438,6 +2438,7 @@ llist_del(&parent->entry); vty->node = parent->node; vty->priv = parent->priv; + vty->index = parent->index; if (vty->indent) talloc_free(vty->indent); vty->indent = parent->indent; @@ -2648,6 +2649,7 @@ struct vty_parent_node this_node = { .node = vty->node, .priv = vty->priv, + .index = vty->index, .indent = vty->indent, }; struct vty_parent_node *parent = vty_parent(vty); @@ -2923,6 +2925,7 @@ this_node = (struct vty_parent_node){ .node = vty->node, .priv = vty->priv, + .index = vty->index, .indent = vty->indent, }; diff --git a/tests/vty/vty_transcript_test.vty b/tests/vty/vty_transcript_test.vty index 79c9f4c..7df2a60 100644 --- a/tests/vty/vty_transcript_test.vty +++ b/tests/vty/vty_transcript_test.vty @@ -191,12 +191,10 @@ C vty_transcript_test(config-c)# exit vty_transcript_test(config-b)# state -C -vty_transcript_test(config-b)# ### ^ EXPECTED ERROR: this should say B +B vty_transcript_test(config-b)# exit vty_transcript_test(config-a)# state -C -vty_transcript_test(config-a)# ### ^ EXPECTED ERROR: this should say A +A vty_transcript_test(config-a)# nest B2 vty_transcript_test(config-b)# state B2 @@ -205,9 +203,7 @@ C2 vty_transcript_test(config-c)# exit vty_transcript_test(config-b)# state -C2 -vty_transcript_test(config-b)# ### ^ EXPECTED ERROR: this should say B2 +B2 vty_transcript_test(config-b)# exit vty_transcript_test(config-a)# state -C2 -vty_transcript_test(config-a)# ### ^ EXPECTED ERROR: this should say A +A -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32562 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Id408c678d18ba19b1c1394c3fb657536153d2094 Gerrit-Change-Number: 32562 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofm...@sysmocom.de> Gerrit-MessageType: newchange