Skip to content

Fails to run on arm #5

@clausecker

Description

@clausecker

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions