Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] make iw usable for mere mortals
@ 2007-12-20 16:10 Andrew Lutomirski
  2007-12-20 17:50 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Lutomirski @ 2007-12-20 16:10 UTC (permalink / raw)
  To: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 396 bytes --]

[Sorry for attached patch, but I fully expect my mailer to butcher it
otherwise.]

iw currently works, but the error handling is a bit off, many error
messages are absent, and the help text is flat-out wrong.  This
partially fixes the above and should make it possible for noobs to add
and remove interfaces without reading the entire source.

Signed-Off-By: Andy Lutomirski <luto@myrealbox.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: iw_usability.patch --]
[-- Type: text/x-patch; name=iw_usability.patch, Size: 1733 bytes --]

diff --git a/interface.c b/interface.c
index b54a66c..efc2d93 100644
--- a/interface.c
+++ b/interface.c
@@ -55,7 +55,7 @@ static int get_if_type(int *argc, char ***argv, enum nl80211_iftype *type)
 static int handle_interface_add(struct nl80211_state *state,
 				char *phy, char *dev, int argc, char **argv)
 {
-	char *name = argv[0];
+	char *name;
 	enum nl80211_iftype type;
 	int tpset, err;
 	struct nl_msg *msg;
@@ -65,14 +65,15 @@ static int handle_interface_add(struct nl80211_state *state,
 		return -1;
 	}
 
+	name = argv[0];
 	argc--;
 	argv++;
 
-	if (argc) {
-		tpset = get_if_type(&argc, &argv, &type);
-		if (tpset < 0)
-			return -1;
-	}
+	tpset = get_if_type(&argc, &argv, &type);
+	if (tpset == 0)
+		fprintf(stderr, "you must specify an interface type\n");
+	if (tpset <= 0)
+		return -1;
 
 	if (argc) {
 		fprintf(stderr, "too many arguments\n");
@@ -150,8 +151,10 @@ int handle_interface(struct nl80211_state *state,
 {
 	char *cmd = argv[0];
 
-	if (argc < 1)
+	if (argc < 1) {
+		fprintf(stderr, "you must specify an interface command\n");
 		return -1;
+	}
 
 	argc--;
 	argv++;
diff --git a/iw.c b/iw.c
index c2b53ee..469bf0e 100644
--- a/iw.c
+++ b/iw.c
@@ -92,8 +92,11 @@ static int get_phy_or_dev(int *argc, char ***argv, char **name)
 
 void usage(char *argv0)
 {
-	fprintf(stderr, "Usage: %s [options] {dev <phydev>} {interface <interface> } {COMMAND}\n"
-			"where COMMAND := { add | del }\n", argv0);
+	fprintf(stderr, "Usage: %s dev <phydev> interface <COMMAND> [OPTIONS]\n"
+			"where COMMAND := { add | del }\n"
+			"\n"
+			"For add, OPTIONS := <name> type <type>\n"
+			"For del, OPTIONS should be blank and phydev is the interface to delete.\n", argv0);
 }
 
 int main(int argc, char **argv)

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

* Re: [PATCH] make iw usable for mere mortals
  2007-12-20 16:10 [PATCH] make iw usable for mere mortals Andrew Lutomirski
@ 2007-12-20 17:50 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2007-12-20 17:50 UTC (permalink / raw)
  To: Andrew Lutomirski; +Cc: linux-wireless

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]



> iw currently works, but the error handling is a bit off, many error
> messages are absent, and the help text is flat-out wrong.  This
> partially fixes the above and should make it possible for noobs to add
> and remove interfaces without reading the entire source.

Applied, thanks. Please copy me on iw patches though.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

end of thread, other threads:[~2007-12-20 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-20 16:10 [PATCH] make iw usable for mere mortals Andrew Lutomirski
2007-12-20 17:50 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox