Skip to content

Commit 732ad2d

Browse files
committed
Fix crash on non-Linux if -S is used
Also move short options near long options table so it is easier to maintain.
1 parent dd5ff8f commit 732ad2d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

uhubctl.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ static int opt_nodesc = 0; /* skip querying device description */
230230
static int opt_nosysfs = 0; /* don't use the Linux sysfs port disable interface, even if available */
231231
#endif
232232

233+
234+
static const char short_options[] =
235+
"l:L:n:a:p:d:r:w:s:hvefRN"
236+
#ifdef __gnu_linux__
237+
"S"
238+
#endif
239+
;
240+
233241
static const struct option long_options[] = {
234242
{ "location", required_argument, NULL, 'l' },
235243
{ "vendor", required_argument, NULL, 'n' },
@@ -1021,8 +1029,7 @@ int main(int argc, char *argv[])
10211029
int option_index = 0;
10221030

10231031
for (;;) {
1024-
c = getopt_long(argc, argv, "l:L:n:a:p:d:r:w:s:hvefRNS",
1025-
long_options, &option_index);
1032+
c = getopt_long(argc, argv, short_options, long_options, &option_index);
10261033
if (c == -1)
10271034
break; /* no more options left */
10281035
switch (c) {

0 commit comments

Comments
 (0)