Skip to content

Commit

Permalink
imx_uart: fix option parsing on ARM and other signed-char systems
Browse files Browse the repository at this point in the history
imx_uart assigns the return value of getopt_long() to a char variable.

On systems that default to unsigned char (e.g. arm, aarch64, powerpc,
s390) this causes the termination return value -1 to be read as 0xff and
the option parsing loop never terminates, causing the program to get
immediately stuck.

Fix that by using an int which is the actual return type of
getopt_long().

imx_usb already correctly uses int.

This should fix issue boundarydevices#116.

Signed-off-by: Anssi Hannula <[email protected]>
  • Loading branch information
anssih committed Feb 24, 2022
1 parent 30b43d6 commit 085f091
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion imx_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ int parse_opts(int argc, char * const *argv, char const **ttyfile,
char const **conffile, int *verify, int *usertscts,
int *associate, struct sdp_work **cmd_head)
{
char c;
int c;
*conffile = NULL;
*ttyfile = NULL;

Expand Down

0 comments on commit 085f091

Please sign in to comment.