Skip to content

Commit

Permalink
Fix crash on non-Linux if -S is used
Browse files Browse the repository at this point in the history
Also move short options near long options table so it is easier to maintain.
  • Loading branch information
mvp committed Sep 22, 2022
1 parent dd5ff8f commit 732ad2d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions uhubctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ static int opt_nodesc = 0; /* skip querying device description */
static int opt_nosysfs = 0; /* don't use the Linux sysfs port disable interface, even if available */
#endif


static const char short_options[] =
"l:L:n:a:p:d:r:w:s:hvefRN"
#ifdef __gnu_linux__
"S"
#endif
;

static const struct option long_options[] = {
{ "location", required_argument, NULL, 'l' },
{ "vendor", required_argument, NULL, 'n' },
Expand Down Expand Up @@ -1021,8 +1029,7 @@ int main(int argc, char *argv[])
int option_index = 0;

for (;;) {
c = getopt_long(argc, argv, "l:L:n:a:p:d:r:w:s:hvefRNS",
long_options, &option_index);
c = getopt_long(argc, argv, short_options, long_options, &option_index);
if (c == -1)
break; /* no more options left */
switch (c) {
Expand Down

0 comments on commit 732ad2d

Please sign in to comment.