[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH 1/2] i2c-tools: fix 'i2cdetect -l'
From:       Bartosz Golaszewski <bartekgola () gmail ! com>
Date:       2015-04-21 12:29:21
Message-ID: 1429619362-21873-2-git-send-email-bartekgola () gmail ! com
[Download RAW message or body]

Calling 'i2cdetect -l' only displays usage and exits. Fix it by
correctly parsing command-line arguments.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
---
 miscutils/i2c_tools.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index 03bb039..a5b6721 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -1284,13 +1284,17 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
 	unsigned opts;
 
 	opt_complementary = "q--r:r--q:" /* mutually exclusive */
-    			"-1:?3"; /* from 1 to 3 args */
+			    "?3"; /* up to 3 args */
 	opts = getopt32(argv, optstr);
 	argv += optind;
+	argc -= optind;
 
 	if (opts & opt_l)
 		list_i2c_busses_and_exit();
 
+	if (argc < 1)
+		bb_show_usage();
+
 	bus_num = i2c_bus_lookup(argv[0]);
 	fd = i2c_dev_open(bus_num);
 	get_funcs_matrix(fd, &funcs);
-- 
2.1.4

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic