]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
mesh: show mesh parameters when no args are given
authorOla Olsson <ola1olsson@gmail.com>
Wed, 21 Oct 2015 12:13:19 +0000 (14:13 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 21 Oct 2015 12:28:09 +0000 (14:28 +0200)
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.

Signed-off-by: Ola Olsson <ola.olsson@sonymobile.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
mesh.c

diff --git a/mesh.c b/mesh.c
index 460d0c99523d58177ccf2b099d2d5dc183f27a3f..f2415f33a8e921aaa80c3f6c99ff0e218be78ed1 100644 (file)
--- a/mesh.c
+++ b/mesh.c
@@ -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);