filewatcherd
filewatcherd copied to clipboard
Fails to run on arm
On arm, char
is an unsigned type. As c
is of type char
, the loop
while (!argerr
&& (c = getopt_long(argc, argv, "dhw:", longopts, 0)) != -1) {
...
}
doesn't terminate correctly: if getopt_long
returns -1
, this is converted to 255
through the assignment to c
. Hence, the exit condition does not trigger directly. Instead, argerr
is set and the loop exits the next iteration. As a consequence, argument parsing always fails and the utility is unusable.
To fix this error, declare c
to be of type int
, not char
as per documentation for getopt_long
.