rgbled: fixed getopt() handling

this allows the -a option to be used, for example
  rgbled -a 0x55 start
This commit is contained in:
Andrew Tridgell 2013-10-19 15:21:02 +11:00 committed by Lorenz Meier
parent dbb49c035b
commit e3fe443720

View File

@ -574,7 +574,7 @@ rgbled_main(int argc, char *argv[])
int ch;
/* jump over start/off/etc and look at options first */
while ((ch = getopt(argc - 1, &argv[1], "a:b:")) != EOF) {
while ((ch = getopt(argc, argv, "a:b:")) != EOF) {
switch (ch) {
case 'a':
rgbledadr = strtol(optarg, NULL, 0);
@ -590,7 +590,12 @@ rgbled_main(int argc, char *argv[])
}
}
const char *verb = argv[1];
if (optind >= argc) {
rgbled_usage();
exit(1);
}
const char *verb = argv[optind];
int fd;
int ret;