Skip to contentSkip to conversation

mesh: show mesh parameters when no args are given

PATCH Applied Ola Olsson 2 participants 2 messages Oct 21, 2015

lore
Share & tools
lore

Ola Olsson

author
#0 lore raw

PATCH 1/1 mesh: show mesh parameters when no args are given

The help text in "<get|set> mesh_param" says that available parameters will be shown if no args are given but that is not the case - fix that.

Also, add help text if a parameter is given but not found.

---
 mesh.c |   23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
mesh.c +16 -7
index 460d0c9..f2415f3 100644
@@ -286,7 +286,6 @@ static const struct mesh_param_descr *find_mesh_param(const char *name)
 			return _mesh_param_descrs + i;
 	}
 
-	print_all_mesh_param_descr();
 	return NULL;
 }
 
@@ -305,8 +304,10 @@ static int set_interface_meshparam(struct nl80211_state *state,
 	if (!container)
 		return -ENOBUFS;
 
-	if (!argc)
+	if (!argc) {
+		print_all_mesh_param_descr();
 		return 1;
+	}
 
 	while (argc) {
 		const char *name;
@@ -334,8 +335,11 @@ static int set_interface_meshparam(struct nl80211_state *state,
 		}
 
 		mdescr = find_mesh_param(name);
-		if (!mdescr)
+		if (!mdescr) {
+			printf("Could not find the parameter %s.\n", name);
+			print_all_mesh_param_descr();
 			return 2;
+		}
 
 		/* Parse the new value */
 		ret = mdescr->parse_fn(value, &any);
@@ -411,13 +415,18 @@ static int get_interface_meshparam(struct nl80211_state *state,
 {
 	const struct mesh_param_descr *mdescr = NULL;
 
-	if (argc > 1)
+	if (argc == 0) {
+		print_all_mesh_param_descr();
 		return 1;
-
-	if (argc == 1) {
+	} else if (argc == 1) {
 		mdescr = find_mesh_param(argv[0]);
-		if (!mdescr)
+		if (!mdescr) {
+			printf("Could not find the parameter %s.\n", argv[0]);
+			print_all_mesh_param_descr();
 			return 2;
+		}
+	} else {
+		return 1;
 	}
 
 	register_handler(print_mesh_param_handler, (void *)mdescr);
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 6 lines · Ola Olsson

The help text in "<get|set> mesh_param" says that available parameters will be shown if no args are given but that is not the case - fix that.

Also, add help text if a parameter is given but not found.

Applied, thanks.

johannes