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.
On arm,
charis an unsigned type. Ascis of typechar, the loopdoesn't terminate correctly: if
getopt_longreturns-1, this is converted to255through the assignment toc. Hence, the exit condition does not trigger directly. Instead,argerris 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
cto be of typeint, notcharas per documentation forgetopt_long.