Change in libosmocore[master]: vty/command: make some 'struct cmd_element' pointers const

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Fri Oct 23 15:08:49 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/20846 )

Change subject: vty/command: make some 'struct cmd_element' pointers const
......................................................................

vty/command: make some 'struct cmd_element' pointers const

Change-Id: I4a8b3bada44538a5e5711bbc4dccf8b2cf3e2e08
---
M src/vty/command.c
1 file changed, 9 insertions(+), 13 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/vty/command.c b/src/vty/command.c
index 0edfce5..53ebcd8 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -674,7 +674,8 @@
 /*
  * Write one cmd_element as XML via a print_func_t.
  */
-static int vty_dump_element(struct cmd_element *cmd, print_func_t print_func, void *data, const char *newline)
+static int vty_dump_element(const struct cmd_element *cmd, print_func_t print_func,
+			    void *data, const char *newline)
 {
 	char *xml_string = xml_escape(cmd->string);
 	unsigned int i;
@@ -768,7 +769,7 @@
 	return 0;
 }
 
-static bool vty_command_is_common(struct cmd_element *cmd);
+static bool vty_command_is_common(const struct cmd_element *cmd);
 
 /*
  * Dump all nodes and commands associated with a given node as XML via a print_func_t.
@@ -786,16 +787,14 @@
 	print_func(data, "    <description>These commands are available on all VTY nodes. They are listed"
 		" here only once, to unclutter the VTY reference.</description>%s", newline);
 	for (i = 0; i < vector_active(cmdvec); ++i) {
-		struct cmd_node *cnode;
-		cnode = vector_slot(cmdvec, i);
+		const struct cmd_node *cnode = vector_slot(cmdvec, i);
 		if (!cnode)
 			continue;
 		if (cnode->node != CONFIG_NODE)
 			continue;
 
 		for (j = 0; j < vector_active(cnode->cmd_vector); ++j) {
-			struct cmd_element *elem;
-			elem = vector_slot(cnode->cmd_vector, j);
+			const struct cmd_element *elem = vector_slot(cnode->cmd_vector, j);
 			if (!vty_command_is_common(elem))
 				continue;
 			if (elem->attr & CMD_ATTR_DEPRECATED)
@@ -808,8 +807,7 @@
 	print_func(data, "  </node>%s", newline);
 
 	for (i = 0; i < vector_active(cmdvec); ++i) {
-		struct cmd_node *cnode;
-		cnode = vector_slot(cmdvec, i);
+		const struct cmd_node *cnode = vector_slot(cmdvec, i);
 		if (!cnode)
 			continue;
 		if (vector_active(cnode->cmd_vector) < 1)
@@ -820,8 +818,7 @@
 		 * 'name', the second becomes 'name_2', then 'name_3', ... */
 		same_name_count = 1;
 		for (j = 0; j < i; ++j) {
-			struct cmd_node *cnode2;
-			cnode2 = vector_slot(cmdvec, j);
+			const struct cmd_node *cnode2 = vector_slot(cmdvec, j);
 			if (!cnode2)
 				continue;
 			if (strcmp(cnode->name, cnode2->name) == 0)
@@ -835,8 +832,7 @@
 		print_func(data, "    <name>%s</name>%s", cnode->name, newline);
 
 		for (j = 0; j < vector_active(cnode->cmd_vector); ++j) {
-			struct cmd_element *elem;
-			elem = vector_slot(cnode->cmd_vector, j);
+			const struct cmd_element *elem = vector_slot(cnode->cmd_vector, j);
 			if (vty_command_is_common(elem))
 				continue;
 			if (elem->attr & CMD_ATTR_DEPRECATED)
@@ -4195,7 +4191,7 @@
 /*! Return true if a node is installed by install_basic_node_commands(), so
  * that we can avoid repeating them for each and every node during 'show
  * running-config' */
-static bool vty_command_is_common(struct cmd_element *cmd)
+static bool vty_command_is_common(const struct cmd_element *cmd)
 {
 	if (cmd == &config_help_cmd
 	    || cmd == &show_vty_attr_all_cmd

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20846
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4a8b3bada44538a5e5711bbc4dccf8b2cf3e2e08
Gerrit-Change-Number: 20846
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201023/dd44d41c/attachment.htm>


More information about the gerrit-log mailing list