]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: Fix return values when parameters are wrong
authorOla Olsson <ola1olsson@gmail.com>
Mon, 12 Oct 2015 07:34:54 +0000 (09:34 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 13 Oct 2015 09:00:31 +0000 (11:00 +0200)
According to header file, wrong parameters
yield 1 as return value.
Also tried to fix the comments since one part
of it was unreadable.

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

index 87d86ccba6664fdd157d78108c5bf023901a4562..209561d55dc173051e81db04e87a7b802b5a0a1b 100644 (file)
@@ -558,10 +558,8 @@ static int set_mcast_rate(struct nl80211_state *state,
        float rate;
        char *end;
 
-       if (argc != 1) {
-               printf("Invalid parameters!\n");
-               return 2;
-       }
+       if (argc != 1)
+               return 1;
 
        rate = strtod(argv[0], &end);
        if (*end != '\0')
diff --git a/iw.h b/iw.h
index cef9da87aa85c497148470902252714d928e9652..263e8b1e9537b0afbb015db5482fa751d8c343b2 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -48,8 +48,8 @@ struct cmd {
        const enum command_identify_by idby;
        /*
         * The handler should return a negative error code,
-        * zero on success, 1 if the arguments were wrong
-        * and the usage message should and 2 otherwise.
+        * zero on success, 1 if the arguments were wrong.
+        * Return 2 iff you provide the error message yourself.
         */
        int (*handler)(struct nl80211_state *state,
                       struct nl_msg *msg,
diff --git a/ps.c b/ps.c
index b774b7e5da22d93e0d7c340adadced2f47dcb60a..de36d2b4b4a89d4291b80ec86707859daeaefa9b 100644 (file)
--- a/ps.c
+++ b/ps.c
@@ -15,10 +15,8 @@ static int set_power_save(struct nl80211_state *state,
 {
        enum nl80211_ps_state ps_state;
 
-       if (argc != 1) {
-               printf("Invalid parameters!\n");
-               return 2;
-       }
+       if (argc != 1)
+               return 1;
 
        if (strcmp(argv[0], "on") == 0)
                ps_state = NL80211_PS_ENABLED;