From: Ola Olsson Date: Mon, 12 Oct 2015 07:34:54 +0000 (+0200) Subject: iw: Fix return values when parameters are wrong X-Git-Tag: v4.7~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86a9801f97aa4e9abe2fd4e6ce886bb225996ed1;p=thirdparty%2Fiw.git iw: Fix return values when parameters are wrong 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 Signed-off-by: Johannes Berg --- diff --git a/interface.c b/interface.c index 87d86cc..209561d 100644 --- a/interface.c +++ b/interface.c @@ -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 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;