linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iw: Fix return values when parameters are wrong
@ 2015-10-07 16:45 Ola Olsson
  2015-10-08  7:50 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Ola Olsson @ 2015-10-07 16:45 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

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 <ola1olsson@gmail.com>
---
 interface.c |    6 ++----
 iw.h        |    4 ++--
 ps.c        |    6 ++----
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/interface.c b/interface.c
index 4f0821d..e931454 100644
--- a/interface.c
+++ b/interface.c
@@ -559,10 +559,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 cef9da8..263e8b1 100644
--- 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 b774b7e..de36d2b 100644
--- 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;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH] iw: Fix return values when parameters are wrong
@ 2015-10-12  7:34 Ola Olsson
  0 siblings, 0 replies; 3+ messages in thread
From: Ola Olsson @ 2015-10-12  7:34 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Ola Olsson, Ola Olsson

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>
---
 interface.c |    6 ++----
 iw.h        |    4 ++--
 ps.c        |    6 ++----
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/interface.c b/interface.c
index 4f0821d..e931454 100644
--- a/interface.c
+++ b/interface.c
@@ -559,10 +559,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 cef9da8..263e8b1 100644
--- 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 b774b7e..de36d2b 100644
--- 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;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-12  7:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-07 16:45 [PATCH] iw: Fix return values when parameters are wrong Ola Olsson
2015-10-08  7:50 ` Johannes Berg
  -- strict thread matches above, loose matches on Subject: below --
2015-10-12  7:34 Ola Olsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).